一杯清酒邀明月
天下本无事,庸人扰之而烦耳。

.h

1     QGraphicsScene *scene;
2     QGraphicsPixmapItem *theFrame;
3     QMatrix matrix;

.cpp

 1 MainWindow::MainWindow(QWidget *parent) :
 2     QMainWindow(parent),
 3     ui(new Ui::MainWindow)
 4 {
 5     ui->setupUi(this);
 6    // 初始化
 7     scene = new QGraphicsScene(this);
 8     theFrame = new QGraphicsPixmapItem();
 9     theFrame->setFlag(QGraphicsPixmapItem::ItemIsSelectable, false);
10     theFrame->setFlag(QGraphicsPixmapItem::ItemIsMovable, false);
11     theFrame->setFlag(QGraphicsPixmapItem::ItemSendsGeometryChanges);
12 
13     scene->addItem(theFrame);
14 
15     scene->setSceneRect(0,0,4096,2160);//设置 scene 尺寸
16 
17     matrix.scale(0.1, 0.1); //缩放比例
18     ui->graphicsView->setMatrix(matrix);
19     ui->graphicsView->scale(1,-1);
20     ui->graphicsView->setScene(scene);
21     ui->graphicsView->show();
22 }

刷新图像

theFrame->setPixmap(Pixmap);
posted on 2020-02-24 14:37  一杯清酒邀明月  阅读(1953)  评论(0编辑  收藏  举报