QGLWidget updateGL() doesn't update with QTime

2019-09-03 14:21发布

问题:

I have a 'QTimer' object and want to update 'QGLWidget' repeatedly in a given time interval.

My problem is that ,content doesn't get updated ,when I call updateGL() method of 'QGLWidget'.

Here's how I init the QTimer,

rotationTimer=new QTimer();
rotationTimer->setInterval(500);
QObject::connect(rotationTimer, SIGNAL(timeout()), this, SLOT(slotAutoRotate()),Qt::QueuedConnection);

in the slotAutoRotate(),

void RzState3DCurveSelect::slotAutoRotate()
{
    RzStateMachine3DCurves *sm3d =(RzStateMachine3DCurves*) this->getStateMachine();
    setYRotation(yRot+5);       
    sm3d->getQGLWidget()->updateGL(); // <---- call updateGL() of the widget.
    //QApplication::processEvents();

}

I even can see the debug information that I write in side 'paintGL()' method, but the content doesn't get updated, unless I move mouse over the widget or any other interaction.

回答1:

You must use update() instead of updateGL()



标签: c++ qt qt4 timer