Friday, April 20, 2012

How can I change the width/height of all QDockWidgets in a QDockWidgetArea?

I have a PyQt 4 application that has a QMainWindow with docked QDockWidgets in the left and bottom dock areas. I currently have two widgets docked on the left and 2 on the bottom. I'm trying to figure out how I can programmatically move the boundary between the central widget and the dock areas, effectively changing the dock area's width (in the case of the left or right areas) or height (for the top and bottom dock areas).



I can do this manually with the mouse; when I move the cursor over the boundary between the central widget and the dock areas, I get a resize handle that I can use to stretch the dock area. I have yet to find an interface to allow me to do that from my program. I've tried manually resizing the QDockWidget objects themselves (which the documentation recommends against) and the widgets that they wrap (which should work), but that doesn't seem to work. Any ideas?



Specifically, this sort of approach does not work:



dock1.resize(QSize(width, height))
dock2.resize(QSize(width, height))
dock3.resize(QSize(width, height))


Nor does this:



dock1.widget().resize(QSize(width, height))
dock2.widget().resize(QSize(width, height))
dock3.widget().resize(QSize(width, height))




No comments:

Post a Comment