[PyQt] Getting image filename in QLabel->pixmap

James Polk jpolk5001 at yahoo.com
Sat Jun 4 02:12:49 BST 2011


Let's say you create a QLabel and make it an icon, by associating an image file to it,..
like..

      thisPixmap  = QtGui.QPixmap('server:/images/airplane.jpg') )

      thisIcon = QtGui.QLabel(self)
      thisIcon.setPixmap(thisPixmap)

Now let's say that later, in another function...you need to query "thisIcon"
to obtain the name of the image file associated with it ("airplane.png").
How can one do this?  I can't find any function in either the QLabel nor
the QPixmap class that has a way to return the underlying image filename.

QLabel does have "pixmap()"...as in:

      thisIcon.pixmap()

but that doesn't return the image filename,...it returns the pixmap's address.

Using QIcon might be an option,...but I need to use QLabel as it has "move"
functions,...and QIcon doesn't appear to have that...

Any info or suggestions are greatly appreciated,
Cheers,
-Jim



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110603/97283e97/attachment.html>


More information about the PyQt mailing list