qlineedit获取内容数字 点击按钮qlineedit获取内容)


QLineEdit控件与回显模式

EchoMode()方法用来设置回显示模式,有下列4种回显模式。

  • Normal
  • NoEcho
  • Password
  • PasswordEchoOnEdit

代码如下:

import sys
from PyQt5.QtWidgets import QApplication,QWidget,QLineEdit,QFormLayout

class QLineEditDemo(QWidget):
    def __init__(self):
        super().__init__()
        self.setupUI()

    def setupUI(self):
        # 创建4个演示用的QLineEdit
        self.lineEdit_1 = QLineEdit(self)
        self.lineEdit_2 = QLineEdit(self)
        self.lineEdit_3 = QLineEdit(self)
        self.lineEdit_4 = QLineEdit(self)

        # 设置placehoder
        self.lineEdit_1.setPlaceholderText("normal")
        self.lineEdit_2.setPlaceholderText("noEcho")
        self.lineEdit_3.setPlaceholderText("password")
        self.lineEdit_4.setPlaceholderText("passwordEchoOnEdit")

        # 设置回显示模式

        self.lineEdit_1.setEchoMode(QLineEdit.Normal)
        self.lineEdit_2.setEchoMode(QLineEdit.NoEcho)
        self.lineEdit_3.setEchoMode(QLineEdit.Password)
        self.lineEdit_4.setEchoMode(QLineEdit.PasswordEchoOnEdit)

        # 创建一个formLayout
        self.formLayout = QFormLayout()
        self.formLayout.addRow("normal",self.lineEdit_1)
        self.formLayout.addRow("noEcho", self.lineEdit_2)
        self.formLayout.addRow("password", self.lineEdit_3)
        self.formLayout.addRow("passwordEchoOnEdit", self.lineEdit_4)
        self.setLayout(self.formLayout)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    mainWindow = QLineEditDemo()
    mainWindow.show()

    sys.exit(app.exec_())

上一篇:京东快递上门取件收费标准 快递上门取件服务)

下一篇:电子书制作软件免费版APP pdf翻页电子书制作步骤)


蚂蚁钢琴网 2008-2025 www.somall.com.cn 皖ICP备2023010105号
大写数字 热点城市 热点地区 热点街道 热点时间 房贷计算器
钢琴调律 钢琴调音 钢琴调律价格
温馨提示:部分文章图片数据来源与网络,仅供参考!版权归原作者所有,如有侵权请联系删除!
违法和不良信息24小时举报热线:18056540210