简体   繁体   English

将小部件尺寸设置为其他尺寸的一半

[英]Set widget size to half of another's size

In Qt, I have a QDialog with two QTreeView objects. 在Qt中,我有一个带有两个QTreeView对象的QDialog 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 . 我在QVBoxLayout添加。

How can I do this? 我怎样才能做到这一点?

You can use the QVBoxLayout::addWidget() method's stretch argument, like this: 您可以使用QVBoxLayout :: addWidget()方法的stretch参数,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM