Qmake
-
I have created UI using Qtdesigner. I have added my .ui file in python file. But I am not able to see Icons I have set to the TreeWidget I have used. When I searched I understood I need Qmake for that. But I don't know where do I find QMake. Do I have to install it? Or will it come along with pyqt5. Please help me with it.
-
Hey there,
if you have an .ui file, then you need to generate the a python file equivalent, to later load it from your code, like described here https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#option-a-generating-a-python-classPySide, and also PyQt, include the tools to work on ui file, called
pyside6-uic
andpyqt5-uic
respectively, that should be enough to get your application going, but I do encourage you to read the previous tutorial to understand the process. -
But I am not able to see Icons I have set to the TreeWidget I have used.
What exactly do you mean by this? @CristianMaureira's suggestion of generating Python classes from
.ui
files at development time may certianly be a good idea, but I don't know how it relates to whatever problem you are having. -
@JonB I have set Folder Icon to entire TreeWidget in Qtdesigner adding resource file. When I preview the window it shows exactly how I designed with icons. But when I link the file to my .py file (by using loadUi(.ui) ) everything and after running the entire program I am not able to see the icons I have added to TreeWidget.
So is it issue of .qrc files? Or .ui file? -
@Teju
I understand now. With a C++ Qt program, resources get compiled into the final excutable. But obviously with Python there is no such thing. I don't know how resources are accessed from a Python Qt program. You are using PyQt5, you say, so did you Google for, say,pyqt5 access qt resource
, or similar? Does, say, https://www.pythonguis.com/tutorials/qresource-system/ help? I think they are saying you would executepyrcc5 resources.qrc -o resources.py
?Another alternative to consider, especially if you do not have many resources in your app: why bother with resources and this step at all? You could just access the icon in an external file you supply with your Python file(s).
-
@JonB Another alternative to consider, especially if you do not have many resources in your app: why bother with resources and this step at all? You could just access the icon in an external file you supply with your Python file(s).
Sorry I did not get what you mean? Like how do I access the icon externally ? Could you please elaborate?
-
@Teju
It should do, and you should find out why it does not. The usual issue is because it (Qt Designer) puts in a relative path, and at run time that depends on what the current working directory is, which varies depending on how you run your program (and i don't know how you do that). You could ensure you set your working directory to whatever is necessary at the start of your Python script.