[][src]Function qt_qml::qml_register_type_not_available

pub unsafe fn qml_register_type_not_available(
    uri: *const c_char,
    version_major: c_int,
    version_minor: c_int,
    qml_name: *const c_char,
    message: impl CastInto<Ref<QString>>
) -> c_int

This function registers a type in the QML system with the name qmlName, in the type namespace imported from uri having the version number composed from versionMajor and versionMinor, but any attempt to instantiate the type will produce the given error message.

Calls C++ function: int qmlRegisterTypeNotAvailable(const char* uri, int versionMajor, int versionMinor, const char* qmlName, const QString& message).

C++ documentation:

This function registers a type in the QML system with the name qmlName, in the type namespace imported from uri having the version number composed from versionMajor and versionMinor, but any attempt to instantiate the type will produce the given error message.

Normally, the types exported by a plugin should be fixed. However, if a C++ type is not available, you should at least "reserve" the QML type name, and give the user of the unavailable type a meaningful error message.

Returns the QML type id.

Example:

#ifdef NO_GAMES_ALLOWED qmlRegisterTypeNotAvailable("MinehuntCore", 0, 1, "Game", "Get back to work, slacker!"); #else qmlRegisterType<MinehuntGame>("MinehuntCore", 0, 1, "Game"); #endif

This will cause any QML which imports the "MinehuntCore" type namespace and attempts to use the type to produce an error message:

fun.qml: Get back to work, slacker! Game { ^

Without this, a generic "Game is not a type" message would be given.

See also qmlRegisterUncreatableType().