PDA

View Full Version : where is QMetaObject::slotNames in Qt 4.7



davidovv
10th September 2012, 12:07
I am collecting general information about class (derived from QObject) and i want to display available properties, signals and slots.
in Qt 3 there was a method (found it on google)

QStrList QMetaObject::slotNames(bool super = FALSE)
that could collect all slots, even inherited

in Qt 4.7 iterating trough QMetaObject like in example

const QMetaObject* metaObject = obj->metaObject();
QStringList methods;
for(int i = metaObject->methodOffset(); i < metaObject->methodCount(); ++i)
methods << QString::fromLatin1(metaObject->method(i).signature());
I get all methods bot not inherited ones
What am i missing?
Is there a replacement for slotNames in qt 4.7?

pkj
10th September 2012, 14:38
In your code you are using QMetaObject::offset(). What it does is it loops only through the metaobject of the class defined. You can loop from 0 to methodCount() to give you full list. Or you can make a recursive function and call using superclass metaobject by using QMetaObject::superclass() if you need finer control.

davidovv
11th September 2012, 14:54
I did create recoursive function to serch superclass, and found all signals, but then i got double information for slots that were reimplemented,
When i first read (misred) documentation for methodOffset() i didnt realize that when startin from zero i will get all methods from super classes.
Loop from zero is bether way. Thanks.