user821273
user821273

Reputation: 13

QLineEdit can't get anything

i using pyqt develop a dialog, and a LineEidt some like below, but i can't get anything from lineEdit1:

lineEdit1 = QtGui.QLineEdit()
lineEdit1.setEchoMode(2)
passWord = lineEdit1.text()

Upvotes: 1

Views: 457

Answers (2)

Johanna
Johanna

Reputation: 1353

You can execute your code on the editingFinished() signal of QLineEdit. It will be executed when the QLineEdit loses focus.

Upvotes: 0

wong2
wong2

Reputation: 35760

lineEdit1 = QtGui.QLineEdit()
lineEdit1.setEchoMode(2)
passWord = lineEdit1.text()  

of course you can't get anything, because when lineEdit1.text() is executed, I believe there is no characters input into lineEdit1.
You should call passWord = lineEdit1.text() by some action when the input is over, for example, click a button.

Upvotes: 3

Related Questions