开发者

C++/QtTestLib programatically get number of functions in class

开发者 https://www.devze.com 2023-01-15 09:42 出处:网络
Within my C++/QtTestLib Class, how can I get a count of the number of private functions in this class so that I can output it at runtime开发者_C百科?Something like this? (Not tested)

Within my C++/QtTestLib Class, how can I get a count of the number of private functions in this class so that I can output it at runtime开发者_C百科?


Something like this? (Not tested)

QObject obj ();
QMetaObject metaobject = obj.MetaObject();
int num_methods = metaobject.methodCount();
int private_methods = 0;
for (int i=0; i<num_methods; i++) {
  if (metaobject.method(i).access() == QMetaMethod::Private)
     private_methods++;
}

where instead of just QObject you have the class that you need to examine.


ASAIK in C++ this is not possible without third-party parser.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号