In the QVariant exposed C++ API. However its a public method defined from the exposed header of QVariant. It allows me to construct a QVariant by giving it a pointer of my value which is internally copied. That's the only way i have to construct a QVariant which type will be my usertype.
[EDIT]You were right MarekR22, i made a typo when posting my snippets... the code should have read: My bad![/EDIT]
Aren't the public methods exposed in a header file the best documentation for a class?
The conversion isnt working. QVariant::toInt when storing enum values always return 0. i have no idea why. It seems that when constructing a QVariant from a usertype, i won't be able to convert them later.
As i said: That's the only way my QVariant will then carry the right type...
Your first suggestion constructs a QVariant based on QString, the problem is that the typing information is lost when doing that. Your second suggestion is a no-do. QMetaEnum is not actually carying the value of the enum, just its typing information...
To summarize what i need: QVariant can carry both the typing and the value of things... i need to use both, i.e. to be able to first look at QVariant types (To know if they are storing enum values from the same enum), and them compare them.
Any other idea please? An actual working sample code would greatly help...
Pierre.
Bookmarks