-1

图像没有被绘制到屏幕上?

QGraphicsScene *scene = new QGraphicsScene();
scene->setSceneRect(0, 0, 996, 996);
scene->setItemIndexMethod(QGraphicsScene::NoIndex);

QGraphicsView *view = new QGraphicsView();
view->setScene(scene);
view->setRenderHint(QPainter::Antialiasing);
view->setBackgroundBrush(Qt::white);
view->setCacheMode(QGraphicsView::CacheBackground);
view->setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);
view->setDragMode(QGraphicsView::ScrollHandDrag);
view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "Colliding Mice"));
view->resize(1000, 1000);
view->show();

QImage img(996, 996, QImage::Format_ARGB32);
img.load("/home/blabla/scene8.jpg", 0);
QPainter painter(&img);
view->render(&painter, view->sceneRect());
4

1 回答 1

0

用作基础: Display QImage with QtGui

QGraphicsScene *scene = new QGraphicsScene();

QPixmap image;
image.load("/home/blabla/scene8.jpg", 0);
scene->addPixmap(image);
scene->setSceneRect(image.rect());

QGraphicsView *view = new QGraphicsView();
view->setScene(scene);
view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView, "My Plot"));
view->resize(1000, 1000);
view->show();
于 2013-08-08T18:14:22.357 回答