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.
精彩评论