PDA

View Full Version : [Solved] how to hide widget in boxlayout but reserve the empty space



dogeye
12th February 2013, 20:23
Hi

I have a list of widgets inserted into a box layout. When one of the widget is hide(), the empty space will be taken by the rest of the widgets. Is there a way to let the layout keep this space? i don't want the widgets move position automatically. I know i can use a widget to wrap and only hide the child widget, but is there a simpler can do the trick?

Thank you very much.

Santosh Reddy
12th February 2013, 20:43
One simple and quick thing would be to install an event filter on a hidden widget and eat/filter the paint event when hidden

ChrisW67
12th February 2013, 21:09
Other options:
Replace the disappearing widget with a QStackedWidget containing that widget and a blank QWidget as pages. Hiding then becomes switching between the QStackedWidget pages.
Override the disappearing widget's paintEvent() and make it paint or not based on a property.

dogeye
13th February 2013, 01:54
Thank you very much for the help.