Display Images in QGraphicsView
I have placed a QGraphicsView widget on a main window and promoted it to
a custom widget.
I have created a scene attached to the view and added a pixmap to the scene.
I then loaded a jpeg image into the scene.
I copied the drawBackdrop method from the Qt Elastic Nodes sample.
I get the backdrop drawn but can not see the loaded image.
I've just started using designer - I can make this work coding by hand,
but I seem to be missing something when trying to get the image to
display when I do a show() on the top level main window generated by designer.
anyone one have a bit of sample code that works that they could share - would be greatly appreciated.:confused:
Re: Display Images in QGraphicsView
Could you post the code sequence in question? Maybe you're doing something wrong there.
Regards
1 Attachment(s)
Re: Display Images in QGraphicsView
I have attached a compressed tar file with my attempt at getting an image
into a graphicsviewer widget.
thanks
rob
Re: Display Images in QGraphicsView
Yes, I just tested with:
Code:
int main(int argc, char *argv[])
{
scn->setSceneRect( w->rect() );
w->setScene( scn );
w->setFixedSize( 400, 400 );
scn->addPixmap( pix );
w->show();
a.connect( &a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
( yes, this is a very poor example :) ).
I loaded both your jpeg and some others, and also a png. All were OK.
Maybe you have some problems with your jpeg plug-in. Try loading a png instead.
Anyway, you should look at what pixmap.size() return after you load it.
Regards
Re: Display Images in QGraphicsView
Also ,make sure the path is correct.