[PyQt] How to make dock widgets fill space

devan devan.xu at gmail.com
Tue Aug 18 05:20:54 BST 2009


Comment out the following two lines (what are they for?)

#self.mainWidget = QWidget()
#self.setCentralWidget(self.mainWidget)

On Mon, Aug 17, 2009 at 8:03 PM, Dan Davison <davison at stats.ox.ac.uk> wrote:

> A beginners question. The code below sets up a main window with two dock
> widgets (which themselves contain tree/list widgets). However, when it
> starts up, there is an empty area between the two dock widgets (one is
> above, and one below). What is the correct way to set this up so that
> the two dock widgets expand vertically to fill all the space? (The
> commented out setMaximumSize calls didn't seem to have any effect).
>
> Thanks,
>
> Dan
>
> #!/usr/bin/env python
> import sys
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
>
> class MainWindow(QMainWindow):
>
>    def __init__(self, parent=None):
>        super(MainWindow, self).__init__(parent)
>        self.mainWidget = QWidget()
>        self.setCentralWidget(self.mainWidget)
>
>        tdw = QDockWidget("top dock widget", self)
>        tdw.setAllowedAreas(Qt.TopDockWidgetArea)
>        tw = QTreeWidget()
>        tdw.setWidget(tw)
>        self.addDockWidget(Qt.TopDockWidgetArea, tdw)
>
>        # dw.setMaximumSize(dw.maximumSize())
>
>        bdw = QDockWidget("bottom dock widget", self)
>        bdw.setAllowedAreas(Qt.BottomDockWidgetArea)
>        lw = QListWidget()
>        bdw.setWidget(lw)
>        self.addDockWidget(Qt.BottomDockWidgetArea, bdw)
>
>        # ldw.setMaximumSize(ldw.maximumSize())
>
>
> if __name__ == '__main__':
>    app = QApplication(sys.argv)
>    mainWindow = MainWindow()
>    mainWindow.show()
>    app.exec_()
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>



-- 
Best Regards!                                       devan.xu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090818/72ee0cd2/attachment-0001.html


More information about the PyQt mailing list