EchoMode的显示效果

 1 import sys
 2 from PyQt5.QtWidgets import QApplication, QLineEdit, QWidget, QFormLayout
 3 
 4 class lineEditDemo(QWidget):
 5     def __init__(self):
 6         super().__init__()
 7         self.setWindowTitle('QLineEdit 例子')
 8 
 9         flo = QFormLayout()
10         pNormalLineEdit = QLineEdit()
11         pNoEchoLineEdit = QLineEdit()
12         pPasswordLineEdit = QLineEdit()
13         pPasswordEchoOnEditLineEdit = QLineEdit()
14 
15         flo.addRow("Normal", pNormalLineEdit)
16         flo.addRow("NoEcho", pNoEchoLineEdit)
17         flo.addRow("Password", pPasswordLineEdit)
18         flo.addRow("PasswordEchoOnEdit", pPasswordEchoOnEditLineEdit)
19 
20         pNormalLineEdit.setPlaceholderText("Normal")
21         pNoEchoLineEdit.setPlaceholderText("NoEcho")
22         pPasswordLineEdit.setPlaceholderText("Password")
23         pPasswordEchoOnEditLineEdit.setPlaceholderText("PasswordEchoOnEdit")
24 
25         # 设置显示效果
26         pNormalLineEdit.setEchoMode(QLineEdit.Normal)
27         pNoEchoLineEdit.setEchoMode(QLineEdit.NoEcho)
28         pPasswordLineEdit.setEchoMode(QLineEdit.Password)
29         pPasswordEchoOnEditLineEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit)
30 
31         self.setLayout(flo)
32 
33 if __name__ == '__main__':
34     app = QApplication(sys.argv)
35     win = lineEditDemo()
36     win.show()
37     sys.exit(app.exec_())
原文地址:https://www.cnblogs.com/leoych/p/13405312.html