Calculate FPS with QGLWidget - paintGL() is not called
Hi,
I am trying to calculate the fps of my application. I know in general how to do it, but my implemented QGLWidget doesn’t work properly. The paintGL() Method doesn’t get called.
That’ how my own Widget GLWidget looks like:
GLWidget.h
- #include <QGLWidget>
- #include <QTime>
- Q_OBJECT
- public:
- protected:
- void paintGL ();
- private:
- int m_frameCount;
- QTime m_time;
- };
GLWidget.cpp
- #include "glwidget.h"
- #include <QDebug>
- {
- m_frameCount = 0;
- }
- void GLWidget::paintGL()
- {
- if (m_frameCount == 0) {
- m_time.start();
- } else {
- qDebug("FPS is %f ms\n", m_time.elapsed() / float(m_frameCount));
- }
- m_frameCount++;
- qDebug() << "frameCount: " << m_frameCount;
- }
And that’s my main.cpp
- int main(int argc, char *argv[])
- {
- QGraphicsScene scene;
- GLWidget *gl = new GLWidget();
- view.setViewport(gl);
- view.show();
- return a.exec();
- }
My problem is that it works hardware accerlated but the paintGL() Method doesn’t get called…
Any Ideas?
Thanks
0 replies
You must log in to post a reply. Not a member yet? Register here!

