QGLWidget updateGL() 不使用 QTimer 更新? [英] QGLWidget updateGL() doesn't update with QTimer?

查看:50
本文介绍了QGLWidget updateGL() 不使用 QTimer 更新?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个QTimer"对象,想在给定的时间间隔内重复更新QGLWidget".

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

我的问题是,当我调用QGLWidget"的 updateGL() 方法时,内容没有更新.

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

这是我如何初始化 QTimer,

Here's how I init the QTimer,

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

在 slotAutoRotate() 中,

in the slotAutoRotate(),

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

}

我什至可以看到我在 'paintGL()' 方法中编写的调试信息,但内容不会更新,除非我将鼠标移到小部件或任何其他交互上.

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.

推荐答案

你必须使用 update() 而不是 updateGL()

You must use update() instead of updateGL()

这篇关于QGLWidget updateGL() 不使用 QTimer 更新?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆