c++ - QMetaMethods for regular methods missing? -
i'm new in qt, , i'm testing out moc. 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 list of methods in class, seem getting list of signals , slots, although documentation says should methods? here's 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 = 0; != cntmo.methodcount(); ++i) { qmetamethod qmm(cntmo.method(i)); cout << qmm.signature() << endl; } return app.exec(); }
please beware best c/p, perhaps forgot include headers.
my output:
destroyed(qobject*) destroyed() deletelater() _q_reregistertimers(void*) valuechanged(int) setvalue(int)
does know why happening? qt not recognise
int value() {return m_value;}
as valid method? if so, there macro i've forgotten or that?
p.s. i'm using 4.6.2
update
i forgot implementation of setvalue
method, not makes difference actual question.
void counter::setvalue(int value) { if(value != m_value) { m_value = value; emit valuechanged(value); } }
as far remember can't access methods of qobject subclass through qmetaobject provides access signals, slots , invocable methods:
class myclass: public qobject { q_object public: q_invocable int somemethod(const qstring &someparam); };
maybe it's provide access q_property getters , setters. read articles qt object model , meta object system more carefully.
quotation qmetaobject class description (http://doc.trolltech.com/4.6/qmetaobject.html#details):
"method() , methodcount() provide information class's meta-methods (signals, slots , other invokable member functions)."
there no information normal c++ methods access. , it's since reflective techniques slow.
Comments
Post a Comment