>Strongly-typed enums need to be used as a completely separate type. You need 
>to declare them as metatypes, load them into a QVariant using 
>>QVariant::fromValue and retrieve using qvariant_cast<EnumType>().

When you say completely separate do you mean the enum can't be part of a class? 
The code I'm updating looks like:
class Foo : public QObject
{
        Q_OBJECT

public:
        enum eFoo
        {
                Foo1,
                Foo2
        };
};

I've updated it to look like:
class Foo : public QObject
{
        Q_OBJECT

public:
        enum class eFoo
        {
                Foo1,
                Foo2
        };
};
Q_DECLARE_METATYPE(Foo::eFoo)

That compiles fine, but this code:
        eFoo foo = Foo::eFoo::Foo1;
        QVariantMap map;
        map.insert("foo", QVariant::fromValue(foo));
fails to compile with the error "Type is not registered, please use the 
Q_DECLARE_METATYPE macro to make it known to Qt's meta-object system".

Is this just not possible?

Thanks.



_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to