PDA

View Full Version : Hiding layouts in BorderLayout - how to?



Acamapichtli
15th August 2013, 19:57
Hi

I write application which uses BorderLayout (http://qt-project.org/doc/qt-5.0/qtwidgets/layouts-borderlayout.html).

I have one main layout in the center, and additionaly one in the bottom, and one on the left side:

Center layout has only QTextEdit, and it's filling almost entire space of the window
South layout has few QLabels and QLineEdit
West layout has little more various controls (and will have more in future, so I plan to add here QDockWidget)


I want to have possiblity to toggle hide/show South and West layout with custom keyboard shortcut when QTextEdit is active. Unfortunately BorderLayouts don't have hide() option.
I could hide one control by one, but:

this could be laborious
even if I did this, there is small space visible in the rest of South or West panel, I can set this in BorderLayout.cpp constructor, but as I said, manual hiding all controls will be hard


My question: how can I easily toggle show/hide some layouts in BorderLayout? I appreciate any help.

Santosh Reddy
16th August 2013, 06:08
I have one main layout in the center, and additionaly one in the bottom, and one on the left side:
- Center layout has only QTextEdit, and it's filling almost entire space of the window
- South layout has few QLabels and QLineEdit
- West layout has little more various controls (and will have more in future, so I plan to add here QDockWidget)
As per border layout example you should have
- Central Widget as QTextEdit
- South widget containng another layout which contains few QLabels and QlineEdit
- West widget containing another layout which contains little more various widges


-West layout has little more various controls (and will have more in future, so I plan to add here QDockWidget)
Why are messing with QDockWidget here?


My question: how can I easily toggle show/hide some layouts in BorderLayout? I appreciate any help.
Note you should have only one border layout which should contain muliple widgets, each of which may contain their specific layouts. Bottom line is you will have to hide/show the widget not the layout in a widget. So get the west / south widget and call hide on it.

Acamapichtli
16th August 2013, 19:12
Thank you for your reply and your corrections, but I'm not sure if I understod you right (I'm not native english speaker).

get the west / south widget and call hide on it.
I can't use something like:

WestWidget->hide();
Even if I'd put in WestWidget some QHBoxLayout, nor I can't do this:

qhboxLayoutInWestWidget->hide();
What do you mean to call hide on them?



Why are messing with QDockWidget here?
West widget has another BorderLayout, and its Center Widget will cotain a lot of layouts and widgets which I want to switch with something (something like TabDialog), but I haven't decided about it yet.