1
votes

I've created a custom QWidget in Qt , in the application , a few instances are created and added to a QVBoxLayout. the problem is: i need the widgets to all remain at a height of 100 pixels. What happens is that the layout seems to be giving each widget an equal portion of the entire window. How do i prevent this?

2

2 Answers

3
votes

You can set a fixed height for your widget :

myWidget->setFixedHeight(100);

You can also set a maximum height if you don't want it to have more than a specific height :

myWidget->setMaximumHeight(100);
1
votes

I usually set minimum and maximum height to the desired fixed value:

myWidget->setMaximumHeight(100);
myWidget->setMinimumHeight(100);