Solved Wrong OpenGL viewport of widget inside QDockWidget
-
Hello. I am drawing stuff on a widget which is inside a QDockWidget and has a 1:1 squared aspect ratio. However, the drawing surface is not properly resized. When the size of the widget is equal to its size hint, the drawing is done properly:
But when it is smaller or bigger, it is not properly drawn:
or
Full source code: https://github.com/Jaime02/Dibujo-tecnico-Cpp
resizeEvent (this keeps a 1:1 aspect ratio):
void Renderer::resizeEvent(QResizeEvent *event){ if (this->width() > this->height()){ this->resize(this->height(), this->height()); } else { this->resize(this->width(), this->width()); } }
-
Hi and welcome to devnet,
You should add which version of Qt you are using as well as platform you run that code on.
-
Hello. Thanks for answering ❤
Qt version: 5.14.2 MinGW 64-bits
Platform: Windows 10, updated.
I have a Python version which works fine, but the c++ version does not. -
Does the python version use the same version of Qt ?
-
@SGaist Yes it does
-
I have created a question here: https://stackoverflow.com/questions/62290688/wrong-opengl-viewport-of-widget-inside-qdockwidget I have included gifs and a Python MRE
-
I found the problem:
There was missing aQOpenGLWidget::resizeEvent(event);
statement at resizeEvent.