Hi,
how to store an custom enum with QSettings and restore it?
Code:
myClass::myEnum m_enum = settings.value("xxx").value<myClass::myEnum>(); // fails because no Qt-class
Thanks
Lykurg
Printable View
Hi,
how to store an custom enum with QSettings and restore it?
Code:
myClass::myEnum m_enum = settings.value("xxx").value<myClass::myEnum>(); // fails because no Qt-class
Thanks
Lykurg
There are a few choices... The simplest is to cast your enum to int (and vice versa). If you need something more complicated, you can use Qt object introspection to map from your enum to QString - there even is a thread that discusses this in this forum. Remember, that if you want to use your custom type with QVariant directly, you have to first register it with the meta-type system. It's described in QVariant docs.