Q_NAMESPACE, Q_ENUM_NS and qmlRegisterUncreatableType
Solved
QML and Qt Quick
-
Hi all,
I want to use the enum mc::Cmd in QML, but I get the error
"error: no member named 'staticMetaObject' in 'mc::Cmd'"
when I try to compile the following:
.hpp file:
#pragma once #include <QObject> namespace mc { Q_NAMESPACE enum Cmd { NoCmd, }; Q_ENUM_NS(Cmd) } // namespace mc #endif
In a .cpp file:
qmlRegisterUncreatableType<mc::Cmd>("MachControl", 1, 0, "Cmd", "Cmd is uncreatable!");
I'm using Qt5.15.18. What am I doing wrong?
Thanks!
-
D DuBu marked this topic as a regular topic on
-
Use qmlRegisterUncreatableMetaObject instead of
qmlRegisterUncreatableType
. The doc shows an example with an enum. -
Use qmlRegisterUncreatableMetaObject instead of
qmlRegisterUncreatableType
. The doc shows an example with an enum. -
D DuBu marked this topic as a question on
-
D DuBu has marked this topic as solved on