I'm building a module that is supposed to display images at a certain rate (not pre defined, but not very high - 10Hz max for the swapping of images).

From my research I got to the conclusion that QGLWidget is the right tool for this task, after enabling vsync with openGL calls(SwapInterval family).

Yet, I am not sure how to actually implement the swapping mechanisem - should I use a timer? If I set a timer for 333.3 ms(3 Hz), when the refresh rate is 60 Hz (16.67 per cycle, thus the timer is 20 cycles), and I be sure that timing will be fine? And if the rate should be 9Hz, I need to set the timer for 100+16.67 because this is the best I can get? And if a timer is ok, should I just call paintGL() when it sends me the timeout event?
Also, do you have any reference to actually displaying an image on a qglwidget? Everything I've tried wan't successful, for example this code:
Qt Code:
  1. void imageDisplay::showImage()
  2. {
  3. glEnable(GL_TEXTURE_2D);
  4. drawTexture(QRect(0,0,1,1),texture,GL_TEXTURE_2D);
  5. glDisable(GL_TEXTURE_2D);
  6.  
  7. }
  8.  
  9. void imageDisplay::loadImage(QImage &img)
  10. {
  11. width_img=img.width();
  12. height_img=img.height();
  13.  
  14. glEnable(GL_TEXTURE_2D); // Enable texturing
  15. glBindTexture(GL_TEXTURE_2D, texture); // Set as the current texture
  16. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width(), img.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
  17. glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
  18. glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
  19. glDisable(GL_TEXTURE_2D);
  20. updateGL();
  21. return;
  22. }
To copy to clipboard, switch view to plain text mode 

only draws a small part of my img on the bottom of the widget

Thanks