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

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_())
秒鲨号所有文章资讯、展示的图片素材等内容均为注册用户上传(部分报媒/平媒内容转载自网络合作媒体),仅供学习参考。用户通过本站上传、发布的任何内容的知识产权归属用户或原始著作权人所有。如有侵犯您的版权,请联系我们反馈!本站将在三个工作日内改正。
(0)

大家都在看

品牌推广 在线咨询
返回顶部