Search code examples
pythonpyqt5qt-designer

How to add background text in QLineEdit


I am working on a python project which includes pyqt5. I am using qt designer to design UI and then writing all of its code. I have a sign in page where user will enter the username and password. It looks like below:

enter image description here

There are two line edit in the above photo. First line edit is for username and second line edit is for password. I don't want to put labels along side line edit to tell user that this is where username is written and same for password. I want to put a background text in first line edit as username and in second as password, so that anyone using it know where to enter username and password. That background text will automatically remove once user starts typing in the line edit.

I am not sure if that thing is called background text or something else as I am a bit weak in UI. Can anyone please tell me how can I do this. Thanks


Solution

  • That property is called placeholderText, if you want to use it in Qt Designer then click on the QLineEdit and in the Property Editor you will find it.