Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make a layout invisible in Qt?

Tags:

layout

qt

I add a layout in a dialog and sometimes I want it and all its containing widgets to hide. How to implement it? I try layout->setEnable(false), but it doesn't seem to work in my tests.

like image 843
user1899020 Avatar asked Jul 30 '13 17:07

user1899020


People also ask

How do you hide labels in Qt?

You can't control the visible property, But if you want to make QLabel looks invisible as default, just set the width/height property to 0 .

How do I hide a layout in Qt?

You should add a widget in your form, put children inside the widget and assign desired layout to the widget. The behavior will be generally the same, but you can use setVisible or hide methods of the widget. Show activity on this post. Transform QLayout to QWidget first, then you can use QWidget->hide().

How do you hide the spacer in Qt?

Try putting the button you want to hide and unhide in another layout. In that layout along with the button put a spacer. Call Button hide and spacer will take over. Spacer takes over hidden button's space.


2 Answers

You can't do that. You should add a widget in your form, put children inside the widget and assign desired layout to the widget. The behavior will be generally the same, but you can use setVisible or hide methods of the widget.

like image 146
Pavel Strakhov Avatar answered Sep 17 '22 03:09

Pavel Strakhov


Transform QLayout to QWidget first, then you can use QWidget->hide(). enter image description here

like image 45
sonichy Avatar answered Sep 18 '22 03:09

sonichy