Results 1 to 4 of 4

Thread: Scale MdiSubWindows after Dockwidget hide()

  1. #1
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Question Scale MdiSubWindows after Dockwidget hide()

    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

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Scale MdiSubWindows after Dockwidget hide()

    Quote Originally Posted by Ginsengelf View Post
    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.

  3. #3
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Scale MdiSubWindows after Dockwidget hide()

    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
    Last edited by Ginsengelf; 6th August 2009 at 14:17. Reason: new insight

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Scale MdiSubWindows after Dockwidget hide()

    Quote Originally Posted by Ginsengelf View Post
    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.
    Qt Code:
    1. QMdiArea::DontMaximizeSubWindowOnActivation
    To copy to clipboard, switch view to plain text mode 

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.