问题描述
我正在研究一个Qt项目,为此项目我需要设计如下内容:
I am working on a Qt Project and for this project I require to design something like this:
到目前为止,我已经在Qt Creator中进行了设计,并且已经准备好组件,但是当我尝试以不同的布局添加小部件时,却没有得到想要的形状.我应该怎么做才能使我的应用程序可调整大小?
I have designed so far in Qt Creator and I have the component ready, but when I am trying to add widget in different layouts, I am not getting the shapes I want. What should I do to make my application resizable?
渔获:
- 侧边栏的宽度是固定的,这意味着对于窗口大小的水平增加,侧边栏的水平宽度不会增加.补充工具栏本身是一个小部件.
- 上方栏的垂直宽度是固定的(如果可能).这意味着,在垂直窗口大小增加的过程中,上栏无法垂直变宽.而且它本身也是一个小部件.
- 侧边栏旁边的小部件位于
qstackedwidget
中.
- Sidebar has fixed width, which means for horizontal increment of window size the sidebar's horizontal width won't increase. Sidebar itself is a widget.
- upperbar's vertical width is fixed (if possible). Which means, during vertical window size increment the upperbar can't become vertically wider. And it itself is also a widget.
- the widgets by the side of sidebar are in a
qstackedwidget
.
推荐答案
嵌套布局:
(绿色正方形= QStackedWidget
)
[定义]
H(x,y,...)= x,y,...;上的水平布局其中x,y,...是小部件(W#)或布局(L#)
H(x, y, ...) = horizontal layouts on x, y, ...; where x, y, ... are widget(W#) or Layout(L#)
V(x,y,...)= x,y,...;上的水平布局;其中x,y,...是小部件(W#)或布局(L#)
V(x, y, ...) = horizontal layouts on x, y, ...; where x, y, ... are widget(W#) or Layout(L#)
- 步骤1: V(W1,W2)= L1
- 步骤2: H(W3,L1)= L2
- 步骤3: V(W4,L2)= L3
- 步骤4:将L3设置为 StackedWidget 布局 的当前页面的布局
- 步骤5: H(W5, StackedWidget )= L4
- 步骤6 :H(W6, 一个分隔符 ,W7)= L5
- 步骤7: V(L5,L4)
- Step 1: V(W1, W2) = L1
- Step 2: H(W3, L1) = L2
- Step 3: V(W4, L2) = L3
- Step 4: Set L3 as the layout of current page of the StackedWidget layout
- Step 5: H(W5, StackedWidget) = L4
- Step 6: H(W6, a spacer, W7) = L5
- Step 7: V(L5, L4)
请注意 W6 和 W7 在水平尺寸上固定(或在其上设置最大值), spacer 在它们之间是布局L5中唯一可调整大小的小部件.
Notice that W6 and W7 are fixed in horizontal size (or set maximum on it), the spacer between them acts as the only resizable widget in the layout L5.
这是层次结构:
这篇关于Qt:在这种情况下应使用哪种布局或布局组合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!