[PyQt] PyQt Newbie Need to use QtDesigner for Tool Button Icons

Felix Schmidt fschmidt at bihl-wiedemann.de
Thu Dec 17 07:49:29 GMT 2009


Hi Richard,
use the "icon" property of the QPushButton.
You don't have to use resources. In QtDesigner you can select "choose 
resource" or "choose file" for every bitmap.
But if you select a file, you have to ensure that it is in the correct 
path, everytime your app starts.
The resource system can transform these bitmaps into source code, which 
can be included in your sources. For example in Qt/C++ the linker would 
include all your data into your executable file.

See http://qt.nokia.com/doc/4.6/resources.html

Felix Schmidt

Richard Parker schrieb:
> I'm starting to redesign an existing application by using PyQt and 
> QtDesigner for the user interface. I want my main window to include a 
> matrix of about 12 tool button widgets that have .jpg or .png images 
> on them that the user can click to select his/her desired features of 
> the application. I notice that in order to place an image onto the 
> tool button, the image has to be listed in a resource file and in 
> reading about resource files for PyQt, it seems that the .qrc files 
> have to be translated into a qrc_resources.py file that I presume 
> needs to be imported into the application. This does not provide the 
> wysiwyg designing experience that I was expecting when using QtDesigner.
>
> What am I missing? And if I need to use the pyrcc4.exe program to 
> convert the .qrc file, how do I attach the images to their respective 
> tool buttons?
>
> If there is a way to use QtDesigner for this purpose, please let me 
> know how to do so.
>
> Thanks.
>
> -rich parker-
> ------------------------------------------------------------------------
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt




More information about the PyQt mailing list