Using QLineEdit for passwords

35,443

Solution 1

setEchoMode (Documentation) for your object.

Example code:

ui->lineEditPassword->setEchoMode(QLineEdit::Password);

You can do it from Qt Designer:

enter image description here

Solution 2

Use setEchoMode and QLineEdit::Password

passwordField->setEchoMode(QLineEdit::Password);

Solution 3

You can using below command to hide text in lineEdit

ui->lineEditPassword->setEchoMode(QLineEdit::Password);
Share:
35,443

Related videos on Youtube

fafa
Author by

fafa

Updated on July 09, 2022

Comments

  • fafa
    fafa almost 2 years

    How can I make a QLineEdit suitable for entering passwords (i.e. it doesn't show what's entered), something like the follwing:

    enter image description here

  • Yun
    Yun over 2 years
    This exact answer has already been submitted by someone else. Please try to avoid duplicate answers.