EchoMode 回显模式
1.Normal
2.NoEcho
3.Password
4.PasswordEchoOnEdit
from PyQt5.QtWidgets import *
import sys
class QLineEditEchoMode(QWidget):
def __init__(self):
super(QLineEditEchoMode, self).__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('LineEdit回显模式')
formLayout = QFormLayout() # 布局
normalLineEdit = QLineEdit()
noEchoLineEdit = QLineEdit()
pwdLineEdit = QLineEdit()
pwdEchoOnLineEdit = QLineEdit()
# 布局设置
formLayout.addRow('Normal',normalLineEdit)
formLayout.addRow('NoEcho',noEchoLineEdit)
formLayout.addRow('Password',pwdLineEdit)
formLayout.addRow('PasswordEchoOnEdit',pwdEchoOnLineEdit)
# 设置LineEdit未输入时的显示信息
normalLineEdit.setPlaceholderText("Normal")
noEchoLineEdit.setPlaceholderText("NoEcho")
pwdLineEdit.setPlaceholderText("Pwd")
pwdEchoOnLineEdit.setPlaceholderText("PwdEcho")
# 设置回显
normalLineEdit.setEchoMode(QLineEdit.Normal)
noEchoLineEdit.setEchoMode(QLineEdit.NoEcho)
pwdLineEdit.setEchoMode(QLineEdit.Password)
pwdEchoOnLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit)
self.setLayout(formLayout)
if __name__ == '__main__':
app = QApplication(sys.argv)
main = QLineEditEchoMode()
main.show()
sys.exit(app.exec_())