manatttta
manatttta

Reputation: 3130

Set widget size to half of another's size

In Qt, I have a QDialog with two QTreeView objects. I want one of them to always be half the height of the other one, and maintain this when I resize my dialog. I add the in a QVBoxLayout.

How can I do this?

Upvotes: 1

Views: 112

Answers (1)

Jeremy Friesner
Jeremy Friesner

Reputation: 73304

You can use the QVBoxLayout::addWidget() method's stretch argument, like this:

layout->addWidget(smallWidget, 1);
layout->addWidget(bigWidget,   2);

Upvotes: 4

Related Questions