tags:

views:

31

answers:

1

Hi,

I have a QGLWidget which draws both 3D and 2D graphics (just like in Qt's overpainting example). The thing is after I added drawing 2D graphics (moved code from paintGL() to paintEvent(), etc.), the widget stopped redrawing most of the times. It didn't redraw after resiging, after loading, and so on. So I put repaint() calls, it helped in some cases, but doesn't help in e.g. resizing.

So which function should I use to refresh the widget? Is it update() or updateGL() or repaint()? Or maybe there is a way to set some mode to enable automatic redrawing after resizing/load/...?

Thanks.

+1  A: 

You should usually use 'update', as this will allow multiple queued paint events to be 'collapsed' into a single event. The update method will call updateGL for QGLWidgets. The 'repaint' method should be used if you want an immediate repaint.

If you have hooked up a timer to periodically call 'update', then failure to repaint regularly usually indicates that you're putting stress on the CPU.

Posting some of the code might make it easier to understand issues with resize/initialisation.

sje397