Qt 6.12 LTS is out! See what's new in the release
blog
Enums in Qt 6.2.* How?
-
Hello!
Trying to work previously developed code base with Qt 6.2.8 and got stack with Enums declaring for QML and Qvariant. There are:// Namespace namespace ARB { // Class definitions class EnumClass : public QObject { Q_OBJECT public: enum class Status: int { Error = 0, Ok = 1, Existed = 2, NotExisted = 3 }; Q_ENUM(Status) }; } // namespace ARB Q_DECLARE_METATYPE(ARB::EnumClass::Status)In *.cpp registering class:
qRegisterMetaType<ARB::EnumClass::Status>("Status"); qmlRegisterType<ARB::EnumClass::Status>("Enums", 1, 0, "Status");In QML file:
import Enums 1.0What is missing by me? For now there are error in passing enum from QML to C++:
("Status", QVariant(Invalid))It's even marked in Qt Creator editor in QML (bold font). But not working in reality.
-
B bogong has marked this topic as solved on