[PyQt] QGraphicsPixmapItem not showing set pixmap
David Boddie
dboddie at trolltech.com
Tue Mar 23 16:58:10 GMT 2010
[Resending from the correct address...]
On Mon Mar 22 14:12:10 GMT 2010, dizou wrote:
> I still haven't gotten this to work. Any other suggestions?
>
> I've tried this:
>
> class DisplayItem(QGraphicsPixmapItem):
> def __init__(self, parent, pixmap=None, graphView=None):
> QGraphicsPixmapItem.__init__(self, QPixmap(':/humvee.png'))
>
> and after I do QGraphicsScene.addItem(DisplayItem), nothing shows up.
Are you able to show the pixmap in a QLabel? That's one way to check that
Qt can display it.
> dizou wrote:
> > So I've got a Icons.qrc file; I've got the IconsCompiled.py file. I'm
> > doing import IconsCompiled.
> > print QFile.exists('/.../.../images/humvee.png') returns "True"
> > print QFile.exists(':/images/humvee.png') returns "True"
> > I am still not getting a pixmap displayed on the screen.
OK, so you've compiled a .qrc file to a .py file and imported it. Presumably,
the file contains the data for the pixmap and pyrcc didn't complain, so the
data is there.
Using QFile, you reference the image using ":/images/humvee.png" but you
use ":/humvee.png" when you try to create a QPixmap. What happens when you
create the pixmap with ":/images/humvee.png"?
David
More information about the PyQt
mailing list