Problem with QMetaMethod::returnType with typedef type
-
Hey All,
I'm running into a problem with QMetaMethod::returnType, which is in turn causing my invoke of said function to fail.
The function in Question is declared as:
JSValue require(const QString& fileName);where JSValue is:
typedef uint64_t JSValue;After creating the QObject based class that contains the require function,
I iterate through all the methods using metaObject() to access each individual QMetaMethod info for each function.The problem is that when I get the return type for the require function, it returns 0,
ie. QMetaType::UnknownType, which in turn makes it impossible to use the function via an invoke call, as it does not return the correct return value properly.I'm pretty sure everything else is working correctly, as a different function in the same class with the declaration:
bool verbose(const QString&);
works fine, and return 1 from the returnType() function.Even changing the return type to be an explicit uint64_t still gives the same, problematic, result?
EDIT.
So after some more testing it appears that changing the return type to be qulonglong, results in the function working and it gives the correct return type value, '5' when I the returnType() function. However changing every instance of JSValue to qulonglong is a not a reasonable solution.In the Qt code this is defined as:
typedef quint64 qulonglong;
typedef unsigned __int64 quint64; /* 64 bit unsigned */But changing the original JSValue typedef to be:
typedef unsigned __int64 JSValue;Doesn't work???
Are there some special rules around what types can be used as return types for functions with QMetaMethod?This is really causing me some issues, so any help feedback would be most appreciated.
- James
PS. FYI. on Qt5.15
-
It seems the solution was to use;
qRegisterMetaType<JSValue>("JSValue");
Earlier in the code to register JSValue as a meta Type.
I had already tried this, but was missing the string "JSValue" from the call.
So it seems that both the type and the string are required.All good working now,
Hopefully it will all work in 6.5 too, as it seems Qt has removed the string variant from the SDK. -