PyQt5 Tutorials
About Lesson

In this Lesson we are going to learn creating of PyQt5 QLabel & QLineEdit with Qt Designer, so in this tutorial we want to use Qt Designer, first of all you need to open your Qt Designer. you can write pyqt5designer in your terminal, after opening qt designer, now we want to design our simple application. basically we need a QLabel, QLineEdit with QPushButton, we want to add these widgets in the Qt Designer. also we want to add horizontal layout for the widgets. 

 

 

You need to select the first two widgets and make the Layout Horizontally, after that repeat this for the second two widgets.

PyQt5 QLineEdit & QLabel
PyQt5 QLineEdit & QLabel

 

 

 

Now you need to right click on the window and make the window vertically layout.

Layout Vertically
Layout Vertically

 

 

After that save your ui design and copy the ui file in the script folder of your python installation, now let’s convert our ui file in to python file. make sure that you have copied your file in to Scripts folder. because we are using pyuic5 module for converting our ui file in to python. now open your terminal and write this command.

 

 

Your ui file is converted to python file and this is the code. 

 

 

Just in here we have added a new python code of click_btn() because we have connected this method with the clicked signal of our QPushButton, i want when a user write his name and click on the button, the label text should be changed.

 

 

 

And this is the clicked signal of the QPushButton.

 

 

 

Run the complete code and this is the result.

PyQt5 QLabel & QLineEdit with Qt Designer
PyQt5 QLabel & QLineEdit with Qt Designer