In this article i will discuss about how to access the C++ class enum types and attributes in qml file using Qt c++ qmlRegisterUncreatableType() template function.
qmlRegisterUncreatableType() will register the c++ class type (derived from QObject) as the non-instantiable type with QML type system. So we can not create object for the class in qml file, but we can use the properties ans enumerated types belongs to this class in qml file.
To access the enum values in qml , we have to make it available to meta-object system with the following macro, Otherwise we cannot access in qml file.
To Register the c++ type with qml type system
Here i'm providing the sample code to demonstrate the use of qmlRegisterUncreatableType() to access c++ class attributes and enum types.
qmlRegisterUncreatableType() will register the c++ class type (derived from QObject) as the non-instantiable type with QML type system. So we can not create object for the class in qml file, but we can use the properties ans enumerated types belongs to this class in qml file.
To access the enum values in qml , we have to make it available to meta-object system with the following macro, Otherwise we cannot access in qml file.
Q_ENUMS(enumType)
To Register the c++ type with qml type system
qmlRegisterUncreatableType("ModuleName/uri", MajorVersion, MinorVersion, "QmlName", "message");
Here i'm providing the sample code to demonstrate the use of qmlRegisterUncreatableType() to access c++ class attributes and enum types.