0
我想設置一個佈局管理器。但得到的消息:pyqt4已經有一個佈局。如何「檢測」或更改?
QLayout: Attempting to add QLayout "" to Window "", which already has a layout
如何更改或檢測哪種類型的佈局是?我想使用boxlayout,因爲它似乎是首選。
import sys
from PyQt4 import QtGui as qt
class Window(qt.QMainWindow):
def __init__(self):
super(Window, self).__init__()
#Lav widgets
self.CreateWidgets()
def CreateWidgets(self):
btn = qt.QPushButton("Fetch", self)
btn.clicked.connect(self.GetData)
self.layout = qt.QVBoxLayout(self)
self.setGeometry(560, 240, 800, 600)
self.setWindowTitle("We do not sow")
self.show()
def GetData(self):
print("Hello World!")
app = qt.QApplication(sys.argv)
w = Window()
sys.exit(app.exec_())