.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);