单行文本输入框(QLineEdit)

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

class Example(QWidget):
    def __init__(self):
        super().__init__()
        self.initUI()

    def initUI(self):
        self.resize(250, 155)
        self.setWindowTitle('title')
        # 实例化QLineEdit对象
        self.line_edit = QLineEdit(self)
        # 实例化QLabel对象
        self.label = QLabel(self)
        # 设置标签的位置和大小
        self.label.setGeometry(0, 30, 200, 20)
        # 连接信号和槽
        self.line_edit.textChanged.connect(self.label.setText)
        self.show()

if __name__ == "__main__":
    app = QApplication(sys.argv)
    ex = Example()
    sys.exit(app.exec_())

 PyQt5 文本框

相关文章:

  • 2021-08-05
  • 2022-12-23
  • 2021-09-20
  • 2022-12-23
  • 2021-07-24
  • 2021-12-09
  • 2021-07-01
猜你喜欢
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
相关资源
相似解决方案