QT how to prevent layouts from shrinking when they are empty
-
Hey. I am creating a template look for my application. I have put some layouts just to see how my application is going to look like:
Just to see how my layout is going to look like, I have put labels everywhere, but in my actual application, this information will be dynamically created and custom labels, buttons and etc will be added to layouts.
For example, this grid layout:
Instead of having textLabel, when the program starts it will be empty. If I delete all the labels the gridlayout will shrink and it becomes difficult to visualise how the application is going to look like:
I hope you understand what I mean. Is there any way to ensure the empty layout does not shrink just so I can visually see how is it going to look like when it gets filled?
-
Set a minimum size to your labels
-
@Christian-Ehrlicher
I placed labels just to keep the layout from shrinking. I have to place something in there (buttons, checkboxes or whatever). This is just so I can visually see how its going to look like when I dynamically fill the grid layout.There will not be any widgets (labels) at the start of the application but in mainwindow.ui I would still like to see the layout not shrinked even though there is no widgets inside. Do you know what I mean?
-
@lukutis222 said in QT how to prevent layouts from shrinking when they are empty:
Do you know what I mean?
Yes
Set a minimum size to your labels
-
@lukutis222
As @Christian-Ehrlicher says, put aQLabel
or aQWidget
in with a minimum size to see what it will look like at design time. Then if necessary start by removing/replacing these widgets with whatever you really want immediately after callingsetupUi()
at runtime.