2

I have the following layout: enter image description here

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

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).

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I'm sorry but the "lay out" menu has every option grayed out. This is weird but I tried it in the first place.. I don't know why but everything's grayed out there
I ended up adding the openGL widget dinamically by code with this->ui->graphLayout->addWidget(myOpenGLWidget); and now it works, thank you
@JohnnyPauling If it was grayed out, maybe the GL widget was not a child of the other widget. You could check if it is in the hierarchical tree panel (you can also change the layout from the tree).
1

In Qt5.4 (i didn't test others) new QOpenGLWidget (inside layout) do not resized automatically in my case. I call

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

in resizeEvent(QResizeEvent *event) of parent widget.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.