简体   繁体   English

Qt调整大小在另一个小部件内的小部件

[英]Qt resize widget inside another widget

I have the following layout: 我有以下布局: 在此处输入图片说明

The black rectangles are QVBoxLayouts, the red one is a generic widget container and the blue little rectangle is my custom openGL widget. 黑色矩形是QVBoxLayouts,红色矩形是通用小部件容器,蓝色小矩形是我自定义的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). 我已经为所有布局和小部件设置了调整大小策略,但是我无法让openGL小部件将大小调整到其父区域的大小(图像中的红色矩形)。

I'm a Qt beginner, perhaps I need to use signals and slots to resize the little blue openGL widget to the red one? 我是Qt初学者,也许我需要使用信号和插槽将蓝色的openGL小部件调整为红色的大小? But how? 但是如何?

The QGLWidget should also be in a layout (of any layout type) to resize itself automatically when its parent is resized. QGLWidget也应该位于布局(任何布局类型)中,以便在调整其父级的大小时自动调整自身的大小。

So, for instance, in the designer, left-click on the red "generic widget container", and choose a vertical layout. 因此,例如在设计器中,左键单击红色的“通用窗口小部件容器”,然后选择垂直布局。

In Qt5.4 (i didn't test others) new QOpenGLWidget (inside layout) do not resized automatically in my case. 在Qt5.4(我没有测试其他工具)中,新的QOpenGLWidget(内部布局)在我的情况下不会自动调整大小。 I call 我打电话

LayoutWidget->setGeometry(QRect(0, 0, event->size().width(), event->size().height()));

in resizeEvent(QResizeEvent *event) of parent widget. 在父窗口小部件的resizeEvent(QResizeEvent * event)中。

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

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