简体   繁体   English

Qt Creator在“设计”选项卡中调整小部件的大小

[英]Qt Creator Resizing Widgets in Design Tab

I am having some difficulty resizing widgets inside a layout within the Qt Creator Design tab. 我在调整Qt Creator的“设计”选项卡中的布局内的窗口小部件大小时遇到​​一些困难。

I want to have a vertical layout with a Grid Layout on the top part of the vertical layout and some buttons on the bottom of the vertical layout. 我想要一个垂直布局,在垂直布局的顶部有一个网格布局,在垂直布局的底部有一些按钮。 When I set this up, the Grid Layout section and the Buttons section each take up exactly half of the screen as shown below. 当我进行设置时,“网格布局”部分和“按钮”部分分别占据了屏幕的一半,如下所示。

Current Layout Screenshot 当前布局截图

The design creator does not allow me to adjust the size of either section for some reason. 由于某些原因,设计创建者不允许我调整任一部分的大小。 I want to have the buttons only take up a small portion of the screen vertically (say 10%) and the Grid Layout take up the remainder of the screen (90%). 我希望按钮仅垂直占据屏幕的一小部分(例如10%),而网格布局则占据屏幕的其余部分(90%)。 How can I do that using the Qt Creator Design tab? 如何使用Qt Creator的“设计”标签执行此操作?

Just populate the top layout with a place holder widget that you can use as a container, and set its vertical size policy to MinimumExpanding. 只需使用可以用作容器的占位符小部件填充顶部布局,然后将其垂直大小策略设置为MinimumExpanding。 You should get something like this: 您应该得到这样的内容:

设计师截图

You can set size policies only on widgets, not on layouts. 您只能在窗口小部件上设置大小策略,而不能在布局上设置大小策略。 Therefore you can not achieve what you want without populating the top layout. 因此,如果不填充顶部布局,就无法实现所需的功能。 Finally you can give the grid layout to the contents of the container widget. 最后,您可以为容器小部件的内容提供网格布局。

Adjust the minimum size of your buttons if you want them to be higher. 如果您希望按钮更大,请调整其最小尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM