-1

Image is not being plotted to the screen?

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());
jdl
  • 6,151
  • 19
  • 83
  • 132
  • Where's the rest of the code? After setting up the scene and view, you create a QImage and render a jpg to it. You need to show the code that's adding an object to the scene that contains the QImage, or is this all you have done? – TheDarkKnight Aug 09 '13 at 08:00

1 Answers1

0

using for a basis: 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();
Community
  • 1
  • 1
jdl
  • 6,151
  • 19
  • 83
  • 132