开发者

QLineEdit can't get anything

i using pyqt dev开发者_C百科elop 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()


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜