QtGui.QIcon("filename.png") results in blank button, version PyQt4.4.4

  • Hi, I have the following code to put an "Exit" button on a toolbar (zetcode tutorial).

    @def initUI(self):
    exitAction = QtGui.QAction(QtGui.QIcon('exit.png'),'Exit',self)

    This gives me a toolbar with an invisible button. I can mouse over it, which triggers a little blank raised button, and click it, which causes an exit as it is supposed to. The icon, however, is not present.

    I have been over the Qt forums and version-specific documentation (http://doc.qt.digia.com/4.4/index.html) and have tried many many versions of the above code including creating a QPixmap (because I can not find 'exit.png' in my path, so I believe I need to make my own), and adding a new .png to my working directory. Do I have to draw my own? How do I do that? Is it a command line prompt that pulls up a Paint-like application?

    Supposedly pyqt looks for icons in \usr\share\pixmaps. I used sys.path.append to add this to my sys.path and then I substituted a known .png file for 'exit.png'. I still got the blank button.

    All the help I have seen suggests using QIcon.fromTheme('exit'), but when I tried that I got AttributeError: fromTheme. Does this function not exist in my version? This is for a work project and I am not an admin on my computer, so I've got to do with the version I have. Is there a workaround for v.4.4.4?

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.