Qt分割器布局使用Qt Designer调整行为大小 [英] Qt splitter layout resize behaviour using Qt Designer
问题描述
让我从图片开始帮助我解释一下。 b
$ b
这是我窗体的主窗口。
发生的是:
我们有4标签小部件。左边的标签窗口小部件有一个水平分割器到2个中间的小部件。
两个中间的小部件有一个垂直分割器,左侧和右侧有一个水平分割器。
右侧的小部件在其左侧有一个垂直分割器
所以所有的视图都使用分割器连接。
最后,主窗格以可调整大小的方式使用水平布局。
问题是,最左边和最右边的小部件的宽度是固定的(在设计器中)。
我希望他们的宽度更小。类似于
您可以看到小部件已调整大小。我可以这样做运行应用程序,并手动调整分割器。有没有办法在QtDesigner这样做?我试着玩政策。我没有真的得到任何进一步的。这是否表明我对政策缺乏了解?也许布局一般?
我应该使用什么选项来实现使用QtDesigner所需的布局。我想避免使用代码。
希望我能尽快解决这个问题。
您可以使用水平拉伸和垂直拉伸属性来更改分割的位置。
例如,与顶部中央的 QTabWidget
的垂直伸展和水平拉伸的中央 QSplitter
在1,所有其他值保持在0,你会得到你想要的结果。
当您有多个非零拉伸值时,比例的结果(例如:2中心的垂直拉伸度为2,中央 QTabWidget
s => 2/3和1/3)在设计器中不可见,但在运行应用程序时似乎正在工作。
PS:您还可以实现相同的结果与tabbified QDockWidget
s,但是通过设计师无法进行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 QTabWidget
s => 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 QDockWidget
s but the dock tabbification is not possible through the designer only.
这篇关于Qt分割器布局使用Qt Designer调整行为大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!