View Full Version : show a hidden widget, then hide but get same man window size

28th September 2011, 05:09
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?


28th September 2011, 07:10
Look at the Extension Dialog example.

1st October 2011, 23:18
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?

2nd October 2011, 00:03
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)

2nd October 2011, 01:20
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?