Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Calculate FPS with QGLWidget - paintGL() is not called
Forum Updated to NodeBB v4.3 + New Features

Calculate FPS with QGLWidget - paintGL() is not called

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 3.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qtd1d1
    wrote on last edited by
    #1

    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>

    class GLWidget : public QGLWidget {

    Q_OBJECT
    

    public:
    GLWidget(QWidget *parent = 0 );

    protected:
    void paintGL ();

    private:
    int m_frameCount;
    QTime m_time;

    };@

    GLWidget.cpp

    @#include "glwidget.h"
    #include <QDebug>

    GLWidget::GLWidget(QWidget *parent)
    : QGLWidget(parent)
    {
    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;
    QGLWidget::paintGL();
    

    }
    @

    And that's my main.cpp

    @int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QGraphicsScene scene;
    
    
    QGraphicsView view(&scene);
    
    GLWidget *gl = new GLWidget();
    
    view.setViewport(gl);
    view.setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    
    view.show();
    
    return a.exec&#40;&#41;;
    

    }@

    My problem is that it works hardware accerlated but the paintGL() Method doesn't get called...

    Any Ideas?
    Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved