PyQt6 Tutorials
About Lesson

In this PyQt6 lesson we are going to learn about Creating Button in Qt Designer with PyQt6, we have already learned that how you can create buttons and labels in PyQt6 using coding, now we want to use Qt Designer to do the same functionality.


What is PyQt6 Qt Designer ?

PyQt6 Qt Designer is a visual UI design tool included with the PyQt6 library that allows developers to create and design graphical user interfaces (GUIs) for their PyQt6 applications. Qt Designer provides drag and drop interface for creating and editing GUIs, allowing developers to quickly prototype and design their UIs without having to write any code.

With PyQt6 Qt Designer, developers can create different types of of UI elements such as buttons, labels, text boxes, check boxes, radio buttons and many more. developers can also customize the appearance and behavior of these elements using Qt Designer’s property editor, which provides visual interface for setting properties such as font, color, alignment and size.

Once GUI has been designed in Qt Designer, it can be saved as a .ui file, which is an XML based file format that contains description of the UI elements and their properties. this .ui file can then be loaded into a PyQt6 application using the uic module, which converts the .ui file into Python code that can be used to create and display the UI.

Using PyQt6 Qt Designer can significantly speed up the process of creating and designing GUIs for PyQt6 applications, allowing developers to focus on implementing the underlying functionality of their applications rather than spending time on the UI design.




Open your Qt Designer using pyqt5designer command in your terminal, after that create a new Widget application window, you can drag and drop the QPushButton and QLabel from the Widget Box.

Creating Button in Qt Designer with PyQt6
Creating Button in Qt Designer with PyQt6




If you want to add some stylesheets for your widgets, than you need to right click on your window, after that choose Changestylesheet.

PyQt Change Stylesheet
PyQt Change Stylesheet




After completing the design, save the file and it will be .ui extension file, we need to convert this to py file, we want to use pyuic6 module for this, so run this command in your terminal.



This is the converted file, but we have also added the signal and slot functionality.




This is our method for changing the text and background color of the label.




In here we have connected our clicked signal of the button with the method that we have already created.




Run the code and this is the result.

Creating Button in Qt Designer with PyQt6
Creating Button in Qt Designer with PyQt6