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

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

Making Empty C++ Project: General exception (Exception from HRESULT:0x80131500) Visual Studio Community 2015 -

How to fix java warning for "The value of the local variable is not used " -