我有一个递归函数,它遍历Qt插件的元数据。从QMetaObject获得QMetaType很简单,但是我找不到任何东西可以让我从QMetaObject获得QMetaType。请看下面的例子:
QPluginLoader pluginLoader(pluginPath);
const QMetaObject *pMetaObject = pluginInstance->metaObject();
//how do I get the metatype? in the meantime as I move forward
auto metaMethod = pMetaObject->method(pMetaObject->methodOffset());//QMetaMethod
int returnType = metaMethod.returnType();
auto qMetaType = QMetaType(returnType);//QMetaType for custom class obtained我的插件的entry类和我的方法返回的另一个自定义类都是用qRegisterMetaType()注册的。
发布于 2016-01-26 08:56:04
int id = QMetaType::type(pMetaObject->className());
if (id != QMetaType::UnknownType)
{
QMetaType metaType(id);
...
}https://stackoverflow.com/questions/35005905
复制相似问题