开发者

QLineEdit can't get anything

开发者 https://www.devze.com 2023-03-16 17:56 出处:网络
i using pyqt dev开发者_C百科elop a dialog, and a LineEidt some like below, but i can\'t get anything from lineEdit1:

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

精彩评论

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