问题描述
我正在学习 QGridLayout 并且正在尝试此代码:
from PyQt5.QtWidgets import *
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
self.mainLayout = QGridLayout()
self.header = QLabel("Header",self)
self.mainLayout.addWidget(self.header,1,2)
self.lbl1 = QLabel("Label 1",self)
self.mainLayout.addWidget(self.lbl1,1)
self.lbl2 = QLabel("Label 2",self)
self.mainLayout.addWidget(self.lbl2,2)
self.lbl3 = QLabel("Label 3",self)
self.mainLayout.addWidget(self.lbl3,2,1)
self.lbl4 = QLabel("Label 4",self)
self.mainLayout.addWidget(self.lbl4,2)
self.setLayout(self.mainLayout)
if __name__ == "__main__":
app = QApplication([])
mw = MainWindow()
mw.show()
app.exec_()
但是 QGridLayout 不构成小部件。我得到了这个结果:
如何解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)