Hi all,
I read the documentation about QVariant with the little example that I report here:
MyCustomStruct c;
if (v.canConvert<MyCustomStruct>())
c = v.value<MyCustomStruct>(v);
v = 7;
int i = v.value<int>(); // same as v.toInt()
QString s
= v.
value<QString>
();
// same as v.toString(), s is now "7" MyCustomStruct c2 = v.value<MyCustomStruct>(); // conversion failed, c2 is empty
QVariant v;
MyCustomStruct c;
if (v.canConvert<MyCustomStruct>())
c = v.value<MyCustomStruct>(v);
v = 7;
int i = v.value<int>(); // same as v.toInt()
QString s = v.value<QString>(); // same as v.toString(), s is now "7"
MyCustomStruct c2 = v.value<MyCustomStruct>(); // conversion failed, c2 is empty
To copy to clipboard, switch view to plain text mode
From this, I understand that I can initialize a QVariant variable only with data types supported by QVariant itself. Am I right?
Is there a way to initialize the variable v with a custom type?
Thanks for your anwers! 
Alex
Bookmarks