我有一个正常的QGraphicsView/QGraphicsScene,我想要做的是将QPixmap(.png)加载到图形并手动设置该QPixmap图像的位置。我找到了解决方案,但它们不适用于Qt5。关于如何在Qt5上实现这一点的任何想法?谢谢。更改QGraphicsScene中的Pixmap位置/Qt5中的视图
QGraphicsScene* scene = new QGraphicsScene(QRect(0, 0, 600, 400));
QPixmap Pix(":/test.gif");
// doesnt work
//Pix.setGeometry(QRect(-30, 40, 260, 200));
QGraphicsPixmapItem *item1 = scene->addPixmap(Pix);
// doesnt work
//item1->setPos(-25, 45);
//scene->addPixmap(Pix)->setPos(0,0);
//QGraphicsView* view = new QGraphicsView(ui->centralWidget);
QGraphicsView* view = new QGraphicsView(this);
view->setScene(scene);
你是什么意思“他们不工作”?你看到像素图,它没有被定位,或者你没有看到任何东西? – TheDarkKnight 2014-10-07 13:49:10