• 4709阅读
  • 2回复

关于控件大小的设置(resolved) [复制链接]

上一主题 下一主题
离线sakiola
 
只看楼主 倒序阅读 楼主  发表于: 2009-08-06
以下操作在qt设计器中实现:

我在主窗体中放置了四个widget 当然 不是dockwidget 因为我要自己的布局

所以 我将上边四个 分成两组 分别用两个spletter将这两组widget纵向捆绑

再用一个spletter横向捆绑 并将最外层的spletter设置为centralWidget的

但是目前有这样一个问题:

“主窗体中的这四个widget 是被平均分配大小的 也就是说 主窗体被平均分成了四个大小一样的等份”

而我要的效果是 “需要能够设置一个初始化的大小 让主窗体显示的时候按照我的初始化的值来进行显示”

不知道在这种情况下 应该怎么设置呢? 如果设置最大size或者最小size当然可以办到 可是我不想我做出来的窗体

受到最大最小的限制,不知谁有好的方法?
[ 此帖被sakiola在2009-08-06 15:53重新编辑 ]
NB才是王道
离线jorneyr

只看该作者 1楼 发表于: 2009-08-06
void QSplitter::setSizes ( const QList<int> & list )

Sets the child widgets respective sizes to the values given in the list.

If the splitter is horizontal, the values set the widths of each widget in pixels, from left to right. If the splitter is vertical, the heights of each widget is set, from top to bottom.

Extra values in the list are ignored. If list contains too few values, the result is undefined but the program will still be well-behaved.

The overall size of the splitter widget is not affected. Instead, any additional/missing space is distributed amongst the widgets according to the relative weight of the sizes.

If you specify a size of 0, the widget will be invisible. The size policies of the widgets are preserved. That is, a value smaller then the minimal size hint of the respective widget will be replaced by the value of the hint.

See also sizes().
离线sakiola
只看该作者 2楼 发表于: 2009-08-06
引用第1楼jorneyr于2009-08-06 14:44发表的  :
void QSplitter::setSizes ( const QList<int> & list )
Sets the child widgets respective sizes to the values given in the list.
If the splitter is horizontal, the values set the widths of each widget in pixels, from left to right. If the splitter is vertical, the heights of each widget is set, from top to bottom.
.......

楼上正解!!TKS
NB才是王道
快速回复
限100 字节
 
上一个 下一个