The strange passed value in resizeGL(int w, int h) each time I resize the window
-
Hi,
On Windows10, I implement a MyOpenGLWidet class by inheriting QOpenGLWidget and overwrite the void resizeGL(int w, int h) method.The code snippet is as follows:
class OGLWidget : public QOpenGLWidget, public QOpenGLFunctions { Q_OBJECT public: OGLWidget(); ~OGLWidget() {}; resizeGL(); } void OGLWidget::resizeGL(int width, int height) { //The output width and height are not correct, very small than //actual sizes qDebug() << "The resized width and height is: " << width << ", " << height; m_width = width; m_height = height; } //add the widget m_planningView = new OGLWidget(); QSurfaceFormat format; format.setRenderableType(QSurfaceFormat::OpenGL); format.setProfile(QSurfaceFormat::CoreProfile); format.setVersion(3, 3); format.setSamples(4); m_planningView->setFormat(format); QGridLayout *preOperationLayout = new QGridLayout(); preOperationLayout->addWidget(m_planningView, 0, 0); m_preOperationFrame = new QFrame(); m_preOperationFrame->setFrameStyle(QFrame::Box | QFrame::Raised); m_preOperationFrame->setLayout(preOperationLayout);However, each time as I resize the parent window, I found the passed value of w and h are not correct. The passed value are very small compared with the real size.
Many thanks.
YL -
@Yixun said in The strange passed value in resizeGL(int w, int h) each time I resize the window:
void OGLWidget::resizeGL(int width, int height)
{
//The output width and height are not correct, very small than
//actual sizes
m_width = width;
m_height = height;
}You're missing to call to the base class.
-
I output the size at the beginning of method resizeGL(), so I think it is not related to the calling the base.
I found the reason is the setting of the display. If I set the display with 3840x2160., the output of QScreen is actually 1280x720. If I set the display to 1920x1080 and the output of QScreen is the same and then the resizeGL works.