PyQt5基础学习-QFormLayout(表单布局) 1.QFormLayout().addRow(添加一行表单布局)

添加标签和每一行的文本来构造表单布局

FormLayout.py 

复制代码
"""
表单布局
"""

import sys, math
from PyQt5.QtWidgets import *

class FormForm(QWidget):
    def __init__(self):
        super(FormForm, self).__init__()
        self.setWindowTitle("表单布局")
        self.resize(350, 300)

        formLayout = QFormLayout()

        titleLabel = QLabel("标题")
        authorLabel = QLabel("作者")
        contentLabel = QLabel("内容")

        titleEdit = QLineEdit()
        authorEdit = QLineEdit()
        contentEdit = QTextEdit()

        formLayout.addRow(titleLabel, titleEdit)
        formLayout.addRow(authorLabel, authorEdit)
        formLayout.addRow(contentLabel, contentEdit)

        self.setLayout(formLayout)

if __name__ == "__main__":
    app = QApplication(sys.argv)

    main = FormForm()
    main.show()
    sys.exit(app.exec_())
复制代码

 

posted @   c语言我的最爱  阅读(1020)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
点击右上角即可分享
微信分享提示