FutureSci
FutureSci

Reputation: 1760

How to prevent a custom QWidget from being resized?

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?

Upvotes: 1

Views: 232

Answers (2)

Nejat
Nejat

Reputation: 32695

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);

Upvotes: 3

asclepix
asclepix

Reputation: 8061

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

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

Upvotes: 1

Related Questions