I wanted to know if its possible to hide a vertical layout. I currently have a a horizonatal layout with two vertical layouts.I wanted to hide one of the vertical layouts(with all its content) on button click. Any suggestions on how I could do that.
Instead of inserting vertical layouts directly into your top-level horizontal layout, use container widgets to easily control visibility:
// Create your left and right widgets QWidget* leftWidget = new QWidget(); QVBoxLayout* leftLayout = new QVBoxLayout(leftWidget); QWidget* rightWidget = new QWidget(); QVBoxLayout* rightLayout = new QVBoxLayout(rightWidget); // Populate your vertical layouts here ... QHBoxLayout* horizontalLayout = new QHBoxLayout(parentWidget); horizontalLayout->addWidget(leftWidget); horizontalLayout->addWidget(rightWidget);
Then, you can simply hide or show
rightWidget to effectively control the visibility of everything in the vertical layouts that you have, without having to hide/show each individual widget.