Hey all!!
I have a program with a QGraphicsScene, displayed by a QGraphicsView. What I wanted to do was insert a number of images (using a QPixmap for each) in the QGraphicsScene. I succeeded, but whenever I click one of these images, the program crashes. I get the error message as displayed in the attachment.
Here is some source code:
|
Source code
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
mScene = new QGraphicsScene( this );
mScene->setItemIndexMethod( QGraphicsScene::NoIndex );
mScene->setSceneRect( 0, 0, 800, 700 );
mScene->setBackgroundBrush( Qt::blue );
mView = new QGraphicsView( mScene );
mView->setCacheMode( QGraphicsView::CacheBackground );
mView->setViewportUpdateMode( QGraphicsView::BoundingRectViewportUpdate );
mView->setRenderHint( QPainter::Antialiasing );
mView->setTransformationAnchor( QGraphicsView::AnchorUnderMouse );
mView->setResizeAnchor( QGraphicsView::AnchorViewCenter );
mView->show();
mIcon = new QGraphicsPixmapItem( this );
QPixmap* image = new QPixmap( "Images/Process.png", 0, Qt::AutoColor );
mIcon->setPixmap( *image );
mScene->addItem( mIcon );
|
I can click ANYWHERE in the QGraphicsScene, exept for on the image... any ideas??