PDA

View Full Version : Scale MdiSubWindows after Dockwidget hide()



Ginsengelf
6th August 2009, 14:01
Hi, I have a QMainWindow with two dock widgets, (one in the left and one in the top docking area) and a QMdiArea as central widget with several subwindows.

When I click a button in the menu bar, I want to hide the dock widgets and scale my subwindows in the mdi area to use all the now available space but keep their width/height ratios.

Hiding the dock widgets is easy (hide()), and scaling would be easy too, but I need the size of the area available for the MdiArea before and after the hide() of the dock widgets and I always get the same value for centralWidget()->geometry(), even if I call update() after the hide().

How can I get both the old and the new size to calculate a scaling factor? Or is there another way to achieve my goal?

Ginsengelf

PS: I'm using Qt 4.3.5

yogeshgokul
6th August 2009, 14:26
I want to hide the dock widgets and scale my subwindows in the mdi area to use all the now available space
This is default behavior of QMainWindow. You dont have to take care for that. Play with size policy of central widget. And look at this (http://pepper.troll.no/s60prereleases/doc/mainwindows-dockwidgets.html).

Ginsengelf
6th August 2009, 14:53
Hi, what happens to me is that the MdiArea scales to take up all available space, but my SubWindows stay the same size, they are just moved, not scaled.

To make it clearer:
if I have a DockWidget on the left and a SubWindow with the maximum width (ergo width() == mdiArea.width()), and I hide the DockWidget, I want the width of my SubWindow to grow to its old width + the width of the DockWidget. The height should scale by the same factor.

Ginsengelf

edit: ah, the dock widgets example seems to do what I want, I'll have a look.
edit2: this automatic resize seems to work only if SubWindows are tile()d , if I shrink them to a custom size, they just stay the same :(

yogeshgokul
6th August 2009, 15:00
Hi, what happens to me is that the MdiArea scales to take up all available space, but my SubWindows stay the same size, they are just moved, not scaled.
This is true, they will not change size, until you tell them to do so.
Try re setting this.

QMdiArea::DontMaximizeSubWindowOnActivation