From what I've tried, the indexes for userType()
that are declared by you will start at 256, and then increase by one.
So if you use Q_DECLARE_METATYPE(someType);
, this type will then be returning 256
on userType()
calls. If you then do Q_DECLARE_METATYPE(someOtherType);
, it will be returning 257
and so on.
Also, if you need to check it in the run-time, you can get the value once, and then use it for comparations:
int MyTypeID = QVariant::fromValue(MyType()).userType();
if( someObject.userType == MyTypeID )
{
//do stuff
}
You might also want to look at qRegisterMetaType() function.