元对象

#include 

//#include 
//#include 
#include 

int main(int argc, char *argv[])
{
    QObject obj;
    const QMetaObject *metaObj = obj.metaObject();
    qDebug() << "class name: " << metaObj->className();
    qDebug() << "class info count: " << metaObj->classInfoCount();
    qDebug() << "methods: ";
    // 从QMetaObject::methodOffset()开始打印,使其不会显示父类的方法
    for (int i = metaObj->methodOffset(); i < metaObj->methodCount(); ++i)
        qDebug() << metaObj->method(i).methodType() << " " << metaObj->method(i).methodSignature();
}

你可能感兴趣的:(Qt5.5.0+)