Reputation: 3153
I have a recursive function that is traversing Qt plugin's metadata. It's straightforward to get QMetaObject from QMetaType, but I could not find anything that will let me obtain QMetaType from QMetaObject. Please take a look at the example below:
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
Both my plugin's entry class, and the other custom class that my method returns are registered with qRegisterMetaType().
Upvotes: 0
Views: 386
Reputation: 7592
int id = QMetaType::type(pMetaObject->className());
if (id != QMetaType::UnknownType)
{
QMetaType metaType(id);
...
}
Upvotes: 3