1

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 Answers 2

3

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.