如何使新的小部件填充可用空间? [英] How to make new widgets fill available space?
问题描述
在使新的QT小部件填充所有可用空间时,我遇到了一些麻烦.
I am having some trouble making a new QT widget fill all the available space.
我想在垂直布局(mVisual
)中添加一个小部件(QGLWidget),并调整布局大小,以便mVisual占据最大的面积.
I want to add a widget (a QGLWidget) to the verticle layout (mVisual
) and have the layout resize so that mVisual occupies the maximal amount of area.
我的布局如下:
我的代码是
ui.setupUi(this);
mWidget = new glStream();
//mWidget->setMinimumHeight(480);
//mWidget->setMinimumWidth(480);
ui.mVisual->addWidget(mWidget);
问题是,如果我不手动设置宽度或高度,则在添加时我什至看不到我的小部件!
The problem is that if I don't manually set the width or height I can't even see my widget when I add it!
我唯一能想到的就是执行某种排序或算术运算,例如parentSize-lytControlsSize
,但这听起来很脏,就像MFC.
The only thing I can think of is to perform some sort or arithmetic like parentSize-lytControlsSize
, but this feels dirty and like MFC.
如何布局窗口小部件,以使一个布局(mVisual
)最小,而另一个布局最大?
How can I layout my widgets so that one layout (mVisual
) is minimal, while the other is maximal?
推荐答案
如果将窗口小部件放置在布局中,则窗口小部件将填充其父区域中的所有可用空间,如果要填充而没有边距,请将布局边距设置为0
.
if you put your widget in a Layout, widget fill all available space in their parent area, and if you want to fill without margins, set Layout margins to 0
.
这篇关于如何使新的小部件填充可用空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!