Am I missing something, or does "qmlRegisterSingletonInstance" have a bug?

Viewed 444

We are getting an apparently false error message when we create a singleton instance using the new "qmlRegisterSingletonInstance" function. We create the instance like this in main.cpp:

QScopedPointer<OSClog> OSClog(new class OSClog);
qmlRegisterSingletonInstance("Louma.osclog", 1, 0, "OSClog", OSClog.get() );

But in our QML file, we get this error message on import, claiming the module can't be found: enter image description here

But it CAN be found, and the program compiles and runs correctly.

If we use a different function to create that type, the error message disappears. Using this code instead does not report the error:

qmlRegisterType<OSClog>("Louma.osclog", 1, 0, "OSClog" );

Although we now need to create an instance of the component in main.qml.

We've been putting up with the error message for months, as it was just a minor annoyance until now. We have just discovered that Qt-Designer refuses to load any object that includes that import statement.

enter image description here

Of course, this error is also phony, as the QML_IMPORT_PATH is correct. If we change the code away from "qmlRegisterSingletonInstance" to any of the other registration function, Qt-Designer works correctly.

So, are we doing something wrong with "qmlRegisterSingletonInstance"? Or is this a bug?

Thanks.

1 Answers
Related