views:

61

answers:

1

Hi, I am trying to get the statusbar to update with the FPS of the contents of a QGLWidget. I have connected them as follows (In class MainWin):

glWidget = new GLWidget;
ui.verticalLayout->addWidget(glWidget);

connect(glWidget,       SIGNAL( updateFPSSignal(float)  ),
        this,           SLOT(   updateFPSSlot(float)    ));
}

The slot is as follows:

void MainWin::updateFPSSlot(float fps){
this->statusBar()->showMessage(QString::number(fps), 0);
}

In the MainWin class definition, I have:

public slots:
    void updateFPSSlot(float fps);

And the signal is as follows: (From what I understand, this shouldn't be here, but the program refuses to compile without it).

void GLWidget::updateFPSSignal(float fps){}

I have the following in the GLWidget class definition:

signals:
    void updateFPSSignal(float fps);

After calculating the fps, I call:

emit updateFPSSignal(fps);

However, when the app starts up, the following is printed out:

Object::connect: No such signal QGLWidget::updateFPSSignal(float) in /Users/usm/Desktop/OGLTest/MainWin.cpp:12
Object::connect:  (receiver name: 'MainWinClass')

None of the tutorials I've read seem to be any help, and I'm sure the fix is simple for someone more experienced.

Thanks.

+3  A: 

do you have

class GLWidget : public QGLWidget {

   Q_OBJECT

   /* ... rest of declaration ... */

};

in your class declaration? and have you put your glwidget.h header into the HEADERS section of your .pro file? the implementation of a signal is done by moc, not you.

akira
Ah yes, I put Q_OBJECT in the class declaration and I also needed to run qmake before recompiling. Thanks!
usm
This should also get rid of the need for the braces after the signal declaration, since moc should now be generating an implementation for you.
Caleb Huitt - cjhuitt