Phil
Phil

Reputation: 14671

Qt: How to place widgets in layout with minWidth and percentage based proportions all together

I have a QHBoxLayout and I want to add 3 widgets inside.

QLabel + QLineEdit + Image (QLabel + QImage)

I need QLabel to have a setMinWidth of 100 pixels I need QImage to have a fixed Width I need QLineEdit to use all the available space left in the middle

Now I want QLabel's space to be either: 100 pixels minimum or 15%, whichever is larger.

How can I achieve this?

Thank you.

Upvotes: 1

Views: 2309

Answers (1)

graphite
graphite

Reputation: 2958

Try setStretchFactor:

layout->setStretchFactor(label, 15)
layout->setStretchFactor(line, 100)

Upvotes: 2

Related Questions