PyQt6 Tutorials
About Lesson

In this PyQt6 lesson we are going to learn How to Create QLineEdit in PyQt6, we want to create our QLineEdit using Qt Designer.

 

 

What is QLineEdit in PyQt6 ?

QLineEdit is a widget in PyQt6 that allows the user to enter and edit single line of text. it is commonly used in forms, search boxes, and other applications where the user needs to provide a small amount of text input.

QLineEdit can be customized in different ways, including setting the text that appears initially, providing a placeholder text that disappears when the user starts typing, restricting the input to certain types of characters or formats, and connecting signals to respond to user input events.

 

 

First of all open your Qt Designer using pyqt5designer

  • Add a QLineEdit from widget box
  • Add QLabel and QPushButton, add QHBoxLayout for the Label and Button
  • Set the main window layout as QVBoxLayout

 

QLineEdit with Qt Designer
QLineEdit with Qt Designer

 

 

Save your file, and as you know it is a .ui file, we need to convert this ui file to python file using pyuic6.

 

 

 

This is the converted file, also we have added signal and slot functionality for our button.

 

 

 

This is our method, in this method first we get the value from the lineedit, after that we set that with the label.

 

 

In here we have connected the clicked signal of the QPushButton with our method, so when the user clicks the button, we want to change the text of the label with the input value.

 

 

 

Run the complete code and this is the result.

How to Create QLineEdit in PyQt6
How to Create QLineEdit in PyQt6