Hi there,

I'm new to Qt and tried to set up a QGLWidget. All went fine but there is a small but annoying error when resizing the QMainWindow in which the QGLWidget is put. I'm rendering a simple cube which can be rotated with the mouse.
But when I increase the size of the window and thus of the QGLWidget, it's not repainted and seems to be frozen even though I call updateGL or paintGL respectively. However it does receive mouse events and stuff. The frozen state remains till I minimize the QGLWidget or till I switch between the tabs of a neighbouring QTabWidget(it's neither a parent nor a child of the QGLWidget).
The problem only occurs when increasing the size of the QGLWidget.
I hope there is some help out there as it seems that noone else had the problem(i googled already a lot)...
I even tried to change focus on other elements in the QMainWindow and then back to the QGLWidget.
I tried to decrease the size of QGLWidget by one pixel.
But these things did not work.

Some code:
Qt Code:
  1. void nyGLWidget::initializeGL()
  2. {
  3. glEnable(GL_DEPTH_TEST);
  4. glEnable(GL_CULL_FACE);
  5. glEnable(GL_TEXTURE_2D);
  6. }
  7.  
  8. void nyGLWidget::paintGL()
  9. {
  10. qglClearColor(clearColor);
  11. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  12. glLoadIdentity();
  13. glPushMatrix();
  14. glTranslatef(400.0f, 300.0f, -10.0f);
  15. glRotatef(xRot / 16.0f, 1.0f, 0.0f, 0.0f);
  16. glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f);
  17. glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f);
  18.  
  19. // draw some objects
  20. glPopMatrix();
  21.  
  22. }
  23.  
  24. void nyGLWidget::resizeGL(int width, int height)
  25. {
  26. glViewport(0,0,width,height);
  27. glMatrixMode(GL_PROJECTION);
  28. glLoadIdentity();
  29. glOrtho(0,width,height,0,-1000,1000);
  30. glMatrixMode(GL_MODELVIEW);
  31. updateGL();
  32. }
  33.  
  34. void nyGLWidget::mousePressEvent(QMouseEvent *event)
  35. {
  36. lastPos = event->pos();
  37. }
  38.  
  39. void nyGLWidget::mouseMoveEvent(QMouseEvent *event)
  40. {
  41. int dx = event->x() - lastPos.x();
  42. int dy = event->y() - lastPos.y();
  43.  
  44.  
  45. if (event->buttons() & Qt::LeftButton) rotateBy(8 * dy, 8 * dx, 0);
  46. else if (event->buttons() & Qt::RightButton) rotateBy(8 * dy, 0, 8 * dx);
  47. lastPos = event->pos();
  48. updateGL();
  49. }
  50.  
  51. void nyGLWidget::mouseReleaseEvent(QMouseEvent * /* event */)
  52. {
  53. emit clicked();
  54. }
To copy to clipboard, switch view to plain text mode 


I run Qt 4.6.2 on Windows 7 Home Premium(64 bit).
The project is compiled and programmed in Qt Creator 1.3.1 (32 bit).

Thanking you in anticipation.
With best regards,
Term Dickem.