Results 1 to 5 of 5

Thread: show a hidden widget, then hide but get same man window size

  1. #1
    Join Date
    May 2010
    Posts
    13

    Default show a hidden widget, then hide but get same man window size

    I am developing an application that shows some graphics in a main window. It is dialog based application. One of the widgets showing some graphics is to be hidden as default and to be shown only if a user opts to show it.

    I have the application laid out and I have selected the widgets to appear in a grid layout so that they resize as the window is resized.

    The problem is that when I show my hidden widget, the main application window enlarges to accommodate that widget. But when I hide that widget again, the main window does not shrink back to its original size.

    I have attached an example application that shows this behavior. The application has two widgets arranged in a vertical layout. The top is a large label, the bottom widget is the graphics widget, initially hidden. Choosing to show the widget from the menu shows it, and toggling that menu hides it.

    So how do I make my application window resize back to its original position after I hide widget?

    Thanks.
    Attached Files Attached Files

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: show a hidden widget, then hide but get same man window size


  3. #3
    Join Date
    May 2010
    Posts
    13

    Default Re: show a hidden widget, then hide but get same man window size

    Thanks for pointing to that example. I followed the example's idea, but I am still not able to keep the original size of my main window by showing and hiding the graphic widget. What might I be missing?

  4. #4
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: show a hidden widget, then hide but get same man window size

    Do you mean that the dialog doesn't get smaller when you hide the "extension"?
    If yes you most likely ignored this line: mainLayout->setSizeConstraint(QLayout::SetFixedSize);

    LE: i don't know how you can make a manually resize-able dialog to automatically behave like in the example (i think you might need to set the "older" size values after you hide the "extended" widget)
    Last edited by Zlatomir; 2nd October 2011 at 00:08.

  5. #5
    Join Date
    May 2010
    Posts
    13

    Default Re: show a hidden widget, then hide but get same man window size

    Yes, I am trying to get the window to shrink back to its original size. Also, my main window is resizable. Is there an example I can refer to that does what I am trying to perform?

Similar Threads

  1. Replies: 10
    Last Post: 20th April 2015, 23:24
  2. Replies: 1
    Last Post: 28th July 2011, 18:32
  3. Replies: 0
    Last Post: 26th October 2010, 18:59
  4. MAC: Getting Dock widget show/hide events
    By jay in forum Qt Programming
    Replies: 3
    Last Post: 31st May 2010, 09:07
  5. Replies: 0
    Last Post: 11th May 2009, 03:28

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.