[Interest] Qt support for strongly-typed enums

Tom Isaacson Tom.Isaacson at navico.com
Sat Nov 21 04:08:54 CET 2015


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






More information about the Interest mailing list