How to input a password (password field) in Pyqt4?

Asked

Viewed 676 times

4

To use a field similar to input HTML in Pyqt4, I use QtGui.QLineEdit.

But how do I make a field that looks like the input password, which is a specific field to enter passwords?

You can define the "asterisks" that hide the text typed in Qlineedit itself, or have some specific?

1 answer

4


Use setEchoMode passing as parameter the Enum QLineEdit.Password or QLineEdit.PasswordEchoOnEdit

from PyQt4 import QtGui

#...

txtPw = QtGui.QLineEdit()
txtPw.setEchoMode(QtGui.QLineEdit.Password)
txtPw.show()
  • QLineEdit.Password Shows only "asterisks" when typing some text

  • QLineEdit.PasswordEchoOnEdit Display the typed character and then change to an "asterisk"

See other Enum values echoMode here

Based on this answer

  • 1

    Thanks, young man. That’s right :p

Browser other questions tagged

You are not signed in. Login or sign up in order to post.