PyQt5 Designer Tutorial: Complete Guide to Qt Designer

In this PyQt5 Designer Tutorial we are going to have Complete Guide to Qt Designer, PyQt5 is Python binding of cross platform application framework, Qt. it is popular choice for creating desktop applications with Python. PyQt5 comes with visual editor called Qt Designer that allows you to design and create user interfaces (UI) quickly and efficiently. in this tutorial we are going to explore PyQt5 Designer and its features to create beautiful and functional UIs.

 

 

 

First of all we need to install PyQt5, and you can install that using pip

 

 

So now let’s talk about PyQt5 Designer, PyQt5 Designer is WYSIWYG (what you see is what you get) UI design tool. it allows you to design and customize the UI of your application graphically, PyQt5 Designer is not built in, we need to install separate module to use designer with pyqt5.

 

 

 

You can find Qt Designer after installation inside Qt5-applications > Qt and then bin folder, there designer.exe.

PyQt5 Designer Tutorial: Complete Guide to Qt Designer
PyQt5 Designer Tutorial: Complete Guide to Qt Designer

 

 

 

When you launch PyQt5 Designer, you will see the following interface, and also we have QPushButton to our Qt Designer.

Complete Guide to Qt Designer
Complete Guide to Qt Designer

 

 

After completing your design in PyQt5 Designer, save the file by selecting File -> Save from the menu bar or by pressing Ctrl + S. save the file as simple_ui.ui.

 

 

Your UI is now ready to be used in your PyQt5 application. to use the UI in your Python code, you need to convert the .ui file to Python file. you can do this using the pyuic5 module that comes with PyQt5. run the following command in your terminal:

 

 

This will create Python file called simple_ui.py that contains the code for your UI, and this will be the converted Python File.

 

 

You can now import this file in your Python code and use it to create an instance of your UI.

In the above code we have imported QApplication and QWidget classes from the PyQt5.QtWidgets module. we also imported the Ui_Form class from the simple_ui module that we generated earlier. after that we have created new class called MyWindow and loaded our previous UI designer that was to PY file.

 

 

Run complete code and this will be the result

PyQt5 Designer Tutorial: Complete Guide to Qt Designer
PyQt5 Designer Tutorial: Complete Guide to Qt Designer

 

 

PySide6 GUI Articles

Leave a Comment