QVariant and Pointers
-
Greetings.
I wonder if I can use QVariant to store pointers to a subclass of QGraphicsObject. Overall, I wonder if you can store pointers into QVariant.
-
Hi,
Yes you can, but you have to register it using Q_DECLARE_METATYPE
-
As it was said above you can, but I would advice against it.
I simply do not see any design reason to do it
and it is definitely will be less efficient, readable and more difficult to maintain than normal pointer usage.
Also all QVariant usage cases do not make sense for pointers such as
conversion to different types or serialization.