QGLWidget updateGL() 不随 QTimer 更新?

发布于 2024-10-08 01:58:47 字数 740 浏览 0 评论 0原文

我有一个“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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叹倦 2024-10-15 01:58:47

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

You must use update() instead of updateGL()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文