QLineEdit控件与回显模式
基本功能:输入单行文本
EchoMode(回显模式)
4中回显模式:
- Normal
- NoEcho
- Password
- PasswordEchoOnEdit
from PyQt5.QtWidgets import *
import sys
class QLineEditEchoMode(QWidget):
def __init__(self):
super(QLineEditEchoMode, self).__init__()
self.initUI()
def initUI(self):
self.setWindowTitle('文本输入框的回显模式')
formLayout = QFormLayout()
normalLineEdit = QLineEdit()
noEchoLineEdit = QLineEdit()
passwordLineEdit = QLineEdit()
passwordEchoOnEdit = QLineEdit()
# placeholdertext
normalLineEdit.setPlaceholderText('normal')
noEchoLineEdit.setPlaceholderText('noEcho')
passwordLineEdit.setPlaceholderText('password')
passwordEchoOnEdit.setPlaceholderText('passwordEchoOnEdit')
normalLineEdit.setEchoMode(QLineEdit.Normal)
noEchoLineEdit.setEchoMode(QLineEdit.NoEcho)
passwordLineEdit.setEchoMode(QLineEdit.Password)
passwordEchoOnEdit.setEchoMode(QLineEdit.PasswordEchoOnEdit)
formLayout.addRow('Normal', normalLineEdit)
formLayout.addRow('NoEcho', noEchoLineEdit)
formLayout.addRow('Password', passwordLineEdit)
formLayout.addRow('PasswordEchoOnEdit', passwordEchoOnEdit)
self.setLayout(formLayout)
if __name__ == '__main__':
app = QApplication(sys.argv)
main = QLineEditEchoMode()
main.show()
sys.exit(app.exec_())