[Interest] QGLWidget initial viewport problem
Jean-Pierre Gehrig
jp.gehrig at edeltech.ch
Tue Nov 27 10:31:48 CET 2012
Hello,
I have a QGLWidget in my application which displays it's content in a centered square GL viewport. In resizeGL() I setup the GL viewport with:
int side = qMin(width, height);
glViewport((width - side) / 2, (height - side) / 2, side, side);
The initial glViewport() call doesn't produce the expected result. To have the viewport setup correctly, resizeGL() must be called after the widget has been shown. (i.e. by slightly resizing the window with the mouse). Then the OpenGL content "hops" into the desired size.
I could reproduce the problem by changing one line of the hellogl example:
hellogl/main.cpp, replace line:
window.resize(window.sizeHint());
with
window.resize(800, 200);
then start the application, the Qt Logo is distorted. Slightly resize the window, and hop, the Qt Logo is resized to the correct size.
Any idea why this is happening ?
Thanks for your help!
JP
More information about the Interest
mailing list