[Interest] Using Q_NAMESPACE enum as a Q_PROPERTY type

Peter Klein peter.zrnko at gmail.com
Thu May 7 10:05:14 CEST 2020


Did you register the namespace with qmlRegisterUncreatableMetaObject() ?

And as I remember there is a limitation that all enums under one registered
namespace should be in one file.

Peter

-- 
Peter Klein - peter.zrnko at gmail.com


so 2. 5. 2020 o 22:49 Doogster <thedoogster at gmail.com> napĂ­sal(a):

> I'm having trouble using an enum with Q_NAMESPACE, as a Q_PROPERTY type.
>
> I'm trying to follow this:
> https://www.kdab.com/new-qt-5-8-meta-object-support-namespaces/
>
> I have the following enum:
>
> -
> namespace ConnectionState {
>
>   Q_NAMESPACE
>
>   enum class State : quint8 {Disconnected, Connecting, Connected};
>
>   Q_ENUM_NS(State)
>
> }
> -
>
> On another class I have:
>
> -
> Q_PROPERTY(ConnectionState::State connectionState READ connectionState
> WRITE setConnectionState NOTIFY connectionStateChanged);
> -
>
> Trying to compile that gives me:
>
> /usr/bin/ld: moc_controller.o:(.data.rel.ro+0x30): undefined reference
> to `ConnectionState::staticMetaObject'
>
> The getter, setter and signal are all defined. If I take out the
> Q_PROPERTY declaration, then my code compiles, but then I don't have
> the property to expose to QML.
>
> What am I missing?
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20200507/4bcd0519/attachment.html>


More information about the Interest mailing list