QGLWidget updateGL() 不随 QTimer 更新?
我有一个“QTimer”对象,想要在给定的时间间隔内重复更新“QGLWidget”。
我的问题是,当我调用“QGLWidget”的 updateGL() 方法时,内容没有更新。
这是我初始化 QTimer 的方法,
rotationTimer=new QTimer();
rotationTimer->setInterval(500);
QObject::connect(rotationTimer, SIGNAL(timeout()), this, SLOT(slotAutoRotate()),Qt::QueuedConnection);
在 slotAutoRotate() 中,
void RzState3DCurveSelect::slotAutoRotate()
{
RzStateMachine3DCurves *sm3d =(RzStateMachine3DCurves*) this->getStateMachine();
setYRotation(yRot+5);
sm3d->getQGLWidget()->updateGL(); // <---- call updateGL() of the widget.
//QApplication::processEvents();
}
我什至可以看到我在“paintGL()”方法中编写的调试信息,但内容不会更新,除非我将鼠标移到小部件或任何其他互动。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须使用 update() 而不是 updateGL()
You must use update() instead of updateGL()