PDA

View Full Version : Insert image to QGraphicView



jmarshellk
21st March 2013, 15:28
Hi everyone,

I want to ask, how to insert an image to QGraphicView from file? I already have the file path, but I don't know how to insert it actually.
Could you please help me?
Thank you!

Best regards!

wagmare
22nd March 2013, 06:35
use graphicspixmapitem

QGraphicsScene scene;
scene.setSceneRect( x, y, z, z );
QGraphicsPixmapItem *item = new QGraphicsPixmapItem(QPixmap("mine.png"), &scene);
QGraphicsView view( &scene );

lanz
22nd March 2013, 07:21
You can create QPixmap, then load it from file, and then create QGraphicsPixmapItem with this pixmap and add it to your scene.
http://qt-project.org/doc/qt-4.8/qpixmap.html
http://qt-project.org/doc/qt-4.8/qgraphicspixmapitem.html