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!
What you probably want is a custom
signalon 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.