[Interest] Qt support for strongly-typed enums

NoRulez norulez at me.com
Sat Nov 21 05:31:59 CET 2015


I think yes.

We have also updated an old project and replaced QMap<enumtype, QString> with std::unordered_map<enumtype, QString> where enumtype was a normal "enum" and now converted to "enum class".
Because it seems not possible to use strong enums in the QMetaType.

Please correct me if I'm wrong

Best Regards


> Am 21.11.2015 um 04:08 schrieb Tom Isaacson <Tom.Isaacson at navico.com>:
> 
> I'm moving an old project to Qt5 and since we've upgraded compiler and now have C++11 support I thought I'd change my enums to "enum class". This breaks some code where I add the enum to a QVariantMap in preparation to conversion to JSON so I had to add a static_cast<int>(). But it made me wonder - is this best practice or is there a Qt way of declaring a strongly-typed enum that's compatible with the likes of QVariant?
> 
> Thanks,
> 
> Tom Isaacson
> 
> 
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



More information about the Interest mailing list