c++ - Detect method's origin when parsing it's metadata in Qt -
i have code parses metadata of qt plugin wrote exposes functionality via interface. plugin's main class inherits qobject, when reading metadata, methods declared , publicly available in qobject, among them:
destroyed(object *); objectnamechanged(qstring); etc...
i want parse methods introduced in plugin's main class, , not methods have been inherited qobject, looking @ properties qmetamethod provides, don't see way. have access methods qmetaobject include qobject's methods well.
one way solve parse metadata of qobject exclude it's methods plugin's main class. last resort. wondering if qt provides out of box.
you can use qmetaobject::methodoffset()
method index current class' methods start, , iterate there rather starting @ index 0:
const qmetaobject *object = metaobject(); // gets methods on actual class. (int = object->methodoffset(); < object->methodcount(); ++i) { qdebug() << object->method(i).methodsignature(); } // gets methods, including super classes. (int = 0; < object->methodcount(); ++i) { qdebug() << object->method(i).methodsignature(); }
this works because method numbering ordered super/parent class methods come before child class methods. therefore, if start @ offset child class methods start, skip super class methods.
Comments
Post a Comment