Banjo
11th March 2008, 03:30
Hello
I am new to QT and am having the following problem with a simple test application that I would appreciate a point in the right direction.
I have used the Designer to create the interface as follows:
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(QtCore.QSize(QtCore.QRect(0,0,80 0,600).size()).expandedTo(MainWindow.minimumSizeHi nt()))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.line = QtGui.QFrame(self.centralwidget)
self.line.setGeometry(QtCore.QRect(663,50,20,481))
self.line.setFrameShape(QtGui.QFrame.VLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName("line")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0,0,800,21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.trans late("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
with the main file:
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.createDockWindows()
def createDockWindows(self):
dock1 = QDockWidget("Dock1", self)
dock1.setAllowedAreas(Qt.RightDockWidgetArea)
w = QLabel("Hello")
dock1.setWidget(w)
self.addDockWidget(Qt.RightDockWidgetArea, dock1)
def main():
app = QApplication(sys.argv)
mainwindow = MainWindow()
mainwindow.show()
sys.exit(app.exec_())
main()
The problem that I have is that when the dockwidget is resized by the user, it just goes over the top of the main window. I have tried writing the interface manually and that works but I can't work out why using the designer is different - obviously some operator error but I can't work it out.
Thanks in advance
I am new to QT and am having the following problem with a simple test application that I would appreciate a point in the right direction.
I have used the Designer to create the interface as follows:
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
MainWindow.resize(QtCore.QSize(QtCore.QRect(0,0,80 0,600).size()).expandedTo(MainWindow.minimumSizeHi nt()))
self.centralwidget = QtGui.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.line = QtGui.QFrame(self.centralwidget)
self.line.setGeometry(QtCore.QRect(663,50,20,481))
self.line.setFrameShape(QtGui.QFrame.VLine)
self.line.setFrameShadow(QtGui.QFrame.Sunken)
self.line.setObjectName("line")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QtGui.QMenuBar(MainWindow)
self.menubar.setGeometry(QtCore.QRect(0,0,800,21))
self.menubar.setObjectName("menubar")
MainWindow.setMenuBar(self.menubar)
self.statusbar = QtGui.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QtGui.QApplication.trans late("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8))
with the main file:
class MainWindow(QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.createDockWindows()
def createDockWindows(self):
dock1 = QDockWidget("Dock1", self)
dock1.setAllowedAreas(Qt.RightDockWidgetArea)
w = QLabel("Hello")
dock1.setWidget(w)
self.addDockWidget(Qt.RightDockWidgetArea, dock1)
def main():
app = QApplication(sys.argv)
mainwindow = MainWindow()
mainwindow.show()
sys.exit(app.exec_())
main()
The problem that I have is that when the dockwidget is resized by the user, it just goes over the top of the main window. I have tried writing the interface manually and that works but I can't work out why using the designer is different - obviously some operator error but I can't work it out.
Thanks in advance