从 glwidget 更新 Qt4 状态栏
我有一个包含 QGLWidget
和 QStatusBar
的窗口。我计算 timerEvent
调用内的 fps,但我不知道更新每帧状态栏的“正确”方法。 fps
是GLWidget
的成员变量:
void GLWidget::timerEvent(QTimerEvent* event){
updateGL();
// Calculate FPS.
prevTime = currentTime;
currentTime = runTime.elapsed();
int timeDiff = currentTime - prevTime;
fps = 1000.0/timeDiff;
// Update statusbar with fps here.
}
谢谢!
I've got a window containing a QGLWidget
and a QStatusBar
. I calculate the fps inside a timerEvent
call, but I don't know the 'correct' way to update the statusbar on every frame. fps
is a member variable of GLWidget
:
void GLWidget::timerEvent(QTimerEvent* event){
updateGL();
// Calculate FPS.
prevTime = currentTime;
currentTime = runTime.elapsed();
int timeDiff = currentTime - prevTime;
fps = 1000.0/timeDiff;
// Update statusbar with fps here.
}
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能想要的是连接到
槽
的 GLWidget 上的自定义信号
。在包含 GLWidget 和状态栏的小部件上建立连接:槽函数看起来像这样:
请注意,如果状态栏是自定义类,则可以在该类中创建槽函数,并直接连接到它。无论哪种方式,都应该在包含 GLWidget 和状态栏实例的类中进行连接。
What you probably want is a custom
signal
on the GLWidget that you connect to aslot
. Make the connection on the widget containing both the GLWidget and the status bar:The slot function would look something like this:
Note that if the status bar is a custom class, you can create the slot function in that class, and connect directly to it. Either way, the connection should be made within the class that contains the instances for both the GLWidget and the status bar.