[PyQt] QDockWidget sizing behavior

Baz Walter bazwal at ftml.net
Tue Oct 12 00:04:29 BST 2010


On 11/10/10 15:17, John Wiggins wrote:
> Hello,
>
> I'm laying out part of the UI for my app using a QMainWindow with no central
> widget and 4 dock widgets. I'd like the dock widgets to be sized
> proportionally to each other but they seem to ignore the value returned by
> sizeHint(). Am I missing something?
>
> - John
>
> Here's a concrete example illustrating my problem:

[snip]

>      def createDockWindows(self):
>          dock1 = self.createDockWidget("Dock1", (0.5, 0.75))
>          self.addDockWidget(QtCore.Qt.TopDockWidgetArea, dock1)
>          dock2 = self.createDockWidget("Dock2", (0.5, 0.75))
>          self.addDockWidget(QtCore.Qt.BottomDockWidgetArea, dock2)
>          dock3 = self.createDockWidget("Dock3", (0.5, 0.25))
>          self.splitDockWidget(dock2, dock3, QtCore.Qt.Horizontal)
>          dock4 = self.createDockWidget("Dock4", (0.5, 0.25))
>          self.splitDockWidget(dock1, dock4, QtCore.Qt.Horizontal)

this makes no sense: how can the top dock area and the bottom dock area 
*both* have 75% of the height?

change dock2 to (0.5, 0.25), and dock4 to (0.5, 0.75), and it should 
work correctly (well, it does for me using qt4.7, anyway).

(nb: and don't forget to disable your restoreLayout method before trying :)


More information about the PyQt mailing list