Hi, I'm new in QT, and I'm just testing out the MOC. For a given class:
class Counter : public QObject
{
Q_OBJECT
int m_value;
public:
Counter() {m_value = 0;}
~Counter() {}
int value() {return m_value;}
public slots:
void setValue(int value);
signals:
void valueChanged(int newValue);
};
I want to get a list of all methods in a class, but seem to only be getting a list of signals and slots, although the documentation says it should be all methods? Here's my code:
#include <QCoreApplication>
#include <QObject>
#include <QMetaMethod>
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
const QMetaObject cntmo = Counter::staticMetaObject;
for(int i = 0; i != cntmo.methodCount(); ++i)
{
QMetaMethod qmm(cntmo.method(i));
cout << qmm.signature() << endl;
}
return app.exec();
}
Please beware this is my best c/p, perhaps I forgot to include some headers.
My output:
destroyed(QObject*)
destroyed()
deleteLater()
_q_reregisterTimers(void*)
valueChanged(int)
setValue(int)
Does anyone know why this is happening? Does qt not recognise
int value() {return m_value;}
as a valid method? If so, is there a macro I've forgotten or something like that?
P.S. I'm using 4.6.2
UPDATE
I forgot the implementation of the setValue
method, not that it makes too much a difference to my actual question.
void Counter::setValue(int value)
{
if(value != m_value)
{
m_value = value;
emit valueChanged(value);
}
}