Qt 在另一个小部件中调整小部件的大小 [英] Qt resize widget inside another widget

查看:62
本文介绍了Qt 在另一个小部件中调整小部件的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下布局:

黑色矩形是 QVBoxLayouts,红色是通用小部件容器,蓝色小矩形是我自定义的 openGL 小部件.

The black rectangles are QVBoxLayouts, the red one is a generic widget container and the blue little rectangle is my custom openGL widget.

我已经为所有布局和小部件设置了调整大小策略,但我无法让 openGL 小部件将大小调整到其父区域(图像中的红色矩形)的范围内.

I already set the resize policies for all layouts and widgets, but I can't get the openGL little widget to resize to the extent of his parent's area (the red rectangle in the image).

我是 Qt 初学者,也许我需要使用信号和插槽将蓝色小部件调整为红色小部件的大小?但是如何?

I'm a Qt beginner, perhaps I need to use signals and slots to resize the little blue openGL widget to the red one? But how?

推荐答案

QGLWidget 也应该在(任何布局类型的)布局中,以便在其父级调整大小时自动调整自身大小.

The QGLWidget should also be in a layout (of any layout type) to resize itself automatically when its parent is resized.

例如,在设计器中,左键单击红色的通用小部件容器",然后选择垂直布局.

So, for instance, in the designer, left-click on the red "generic widget container", and choose a vertical layout.

这篇关于Qt 在另一个小部件中调整小部件的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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