How to Use QtDesigner
Subscribe to Tech with Tim
This pyqt5 tutorial will show you how to use the QtDesigner to create GUI applications within a drag and drop interface.
What is QtDesigner?
QtDesigner is a program made by the makers of Qt and PyQt that allows you to build GUI applications with drag and drop. One you have built and saved the application you can run a command line tool that will turn your GUI into python code. This makes it very easy to create GUI's , especially simple ones.
QtDesigner comes with the pip package pyqt5-tools so if you installed it in the previous tutorials you're good to go.
Otherwise run the following command in your command prompt.
pip install pyqt5-tools
and if that doesn't work you can try:
pip3 install pyqt5-tools
Now that we have QtDesigner installed we actually need to find its install location on our computer. Unfortunately this is not that easy.
It should be located in your python install folder under > Lib > site-packages > pyqt5-tool > designer
If you are unable to locate this you can try doing a file search of your entire C drive.
From here simply scroll down until you find designer.
I would recommend creating a shortcut of this and placing it on your desktop.
Now you can launch the designer app and start creating a GUI.
Exporting Your GUI
Once you have created a GUI and want to export it to the python code you need to follow the steps below.
Save your work somewhere you can find it (you'll notice it saves as a .ui file).
Open up a command prompt window in that location.
Run the following:
pyuic5 –x "filename".ui –o "filename".py
Now you should see a file in that same directory as your .ui file that is "filename.py". You can open this and see that it contains the code used to create the GUI you made with drag and drop.