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_())

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM