I have some problems with pyqt. I have to example files:
So, the login.ui, maked with the qt designer uses some resources of the qrc file. The qrc have some images for the buttons created in ui file.
The qrc file is using an directory images, where's the images of the buttons. It works only in the qt designer. If I open in the qt designer of the QtCreator, in C++, it shows the buttons with the respective icons.
My python file "Login.py" is like this:
from PyQt4 import QtGui, uic
import sys
class Form(QtGui.QDialog):
def __init__(self, parent = None):
QtGui.QDialog.__init__(self, parent)
uic.loadUi("login.ui", self)
if __name__ == "__main__":
app = QtGui.QApplication(sys.argv)
ui = Form()
ui.show()
sys.exit(app.exec_())
It's importing the ui file. Now the problem:
When I run the program, the icons don't show. The files are setup in the correct folders. But when I run the app, the icons don't appears.
Should I make some configuration in my python file? Am I missing something?
Thank's guys. ^^
I think you need to compile .qrc file to a Python module and import it for the icons to be loaded into memory.
http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/resources.html
pyrcc4
is PyQt's equivalent to Qt's rcc utility and is used in exactly the same way.pyrcc4
reads the.qrc
file, and the resource files, and generates a Python module that only needs to be import ed by the application in order for those resources to be made available just as if they were the original files.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.