[PyQt] QGraphicsView to display a png

kib2 kib2 at free.fr
Tue Jul 24 00:36:30 BST 2007

David Boddie a écrit :

> Ah, it seems that you were setting up the scene from with a method of
> a class. Your problem was that, when the method returned, the scene
> was garbage collected. Giving it a parent of "self" keeps it alive
> thanks to Qt's parent-child object management. Alternatively, you
> could have stored the scene in the instance of your class; in other
> words, use self.scene instead.

That's why I had to provide a complete simple app now. I must apologize 
as it may have been confusing.

>> Now, Dave just told me it was a bad idea to put an image on a 
>> QGraphicsView. I've already done it inside a Label, but I've no controls 
>> on it. He suggested I've to write my own widget (from Qlabel or QWidget) 
>> for that, but I don't see why it's a bad design decision.
> Well, I guess that was in some private e-mail.

Yes, I thought it was here.

> It really depends on what
> you are going to do with the image, and whether you need to use QGraphicsView
> to show it.

Not some great tasks : I've got some Asymptote code in an editor and 
launch a QProcess to view the output, but the size may vary and I wonder 
finally if I should do this inside a modal widget with a QLabel inside.

>> David : thanks again for your good work on the wiki.
> You're welcome. I notice that you have added a link to your hints and tips
> page. Thanks for doing that. 

No problem, I can add a lot more if it's ok. But I'm going on hollidays 
in 4 days, so you'll certainly have to wait a little :)

In case you were unaware, there's an entire
> French speaking Qt community online at
>   http://www.qtfr.org/

Yes, I know it well. I asked them to build a PyQt group, maybe it will 
be on stage soon.

> Maybe some of the people there can speak Python, too. ;-)

Not so much in fact, but lookin at C++ samples is a great help. That's 
what I've done to build my editor with the line numbers.

> David



More information about the PyQt mailing list