Qt拆分布局使用Qt Designer调整行为 [英] Qt splitter layout resize behaviour using Qt Designer

查看:2017
本文介绍了Qt拆分布局使用Qt Designer调整行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



让我从一个图片开始帮助我解释

$

b
$ b

>



这是我窗体的主窗口。



会发生什么:



选项卡小部件。左选项卡小部件具有到2个中间小部件的水平分割器。
两个中间部件有一个垂直分割器,左右两边有一个水平分割器。



右边的部件左边有一个垂直分割器



所有视图都使用拆分器连接。



最后,mainform以可调整大小的方式使用水平布局。



问题是,最左边和最右边的小部件的宽度是固定的(在设计器中)。
我希望它们的宽度更小。类似的内容:



/ p>

您可以看到窗口小部件的大小。我能够做到这一点运行应用程序,并手动调整分离器。有没有办法在QtDesigner这样做?我试着玩的政策。我没有真的得到任何进一步。这是否表明我对政策缺乏了解?也许布局一般?



我应该使用什么选项来实现所需的布局使用QtDesigner。我想避免使用代码。



希望我能很快解决这个问题。

解决方案

你可以使用Horizo​​ntal Stretch和Vertical Stretch属性来改变



例如,对于顶部中心的垂直伸展 QTabWidget 和水平伸展的中心 QSplitter 在1,所有其他值保持为0,你会得到你想要的结果。



当你有多个非零拉伸值时,比率的结果(例如:2的中心垂直伸展和2中心 QTabWidget s => 2/3和1/3)在设计程序中不可见,但在运行应用程序时似乎正在工作。



PS:使用tabbified QDockWidget 的结果相同,但是只能通过设计器来实现dock tabbification。


I have an issue with size in my view made in Qt with drag and drop.

Let me start with an image to help me explain

This is the mainwindow for my form.

What happens is:

We have 4 tab widgets. the left tab widget has a horizontal splitter to the 2 mid widgets. The 2 mid widgets have a vertical splitter, and a horizontal splitter on the left and right side.

The right widget has a vertical splitter on its left hand.

So all views are connected using splitters.

Lastly the mainform sticks every thing together in a resizable way using horizontal layout.

The problem is, the width of the leftmost and rightmost widgets are fixed (in designer). I want them to be smaller in width. Something similar to:

You can see the widgets are resized. I was able to do this running the application, and manually adjusting the splitters. Is there a way in QtDesigner to do this? I tried playing with policies. I didn't really get any further however. Does this indicate a lack of knowledge of my part about policies? Perhaps layouts in general?

What options should I use to achieve the desired layout using QtDesigner. I want to avoid using code.

Hope I will be able to solve this soon. It must be overlooking something simple..

解决方案

You can play with the "Horizontal Stretch" and "Vertical Stretch" properties to change the position of the split.

For example with both the vertical stretch of the top central QTabWidget and the horizontal stretch of the central QSplitter at 1 and all the other values kept at 0, you'll get the result you want.

When you have multiple non-zero stretch values, the result of the ratio (e.g.: vertical strech at 2 and 1 for the 2 central QTabWidgets => 2/3 and 1/3) is not visible in the designer but seems to be working when you run the application.

PS: You can also achieve the same result with tabbified QDockWidgets but the dock tabbification is not possible through the designer only.

这篇关于Qt拆分布局使用Qt Designer调整行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆