Statically built plugin could not load by engine on qmldir declare in Qt 5.8 rc
Briefly speaking, lets see a code snippet:
I build a plugin named
MyQMLPluginstatically, and import
main.qmlusing the following statement:
Q_IMPORT_PLUGIN( MyQMLPlugin )
What if the QML environment recognize my imported types? This is a question, in my approach, I do the following:
#define QUICK_MODULE_INTIALIZE( PLUGIN, engine, uri ) \ qobject_cast<QQmlExtensionPlugin*>( qt_static_plugin_##PLUGIN().instance( ) ) \ ->registerTypes( uri ); \ qobject_cast<QQmlExtensionPlugin*>( qt_static_plugin_##PLUGIN().instance( ) ) \ ->initializeEngine( engine, uri ); QUICK_MODULE_INTIALIZE( MyQMLPlugin, engine, "QtDream.MyQML" );
All that be done within
main()function after QApplication construction before QQmlApplicationEngine's construction.
Next, is qmldir still necessary? A question left it for everyone, but I import the qmldir in resource path instead of an file path.
In qmldir file, I write:
module QtDream.MyQML plugin MyQMLPlugin classname MyQMLPlugin typeinfo MyQMLPlugin.qmltypes
There is an inconsistency between Qt 5.7.1 and Qt 5.8.0-rc: as there is no so/dll/dylib file in filesystem named "MyQMLPlugin", The engine fails to find with a error:
module "QtDream.MyQML" plugin "MyQMLPlugin" not found, which is absurd because MyQMLPlugin class is imported previousely, before QQmlApplicationEngine's construction. in Qt 5.7.1 it does not produce this error, only ignore the
My question is, is it a bug in Qt 5.8.0-rc or by intention? if is it by intention, how could I do with it elegantly?
@raven-worx Yes, I've read. Finally, I come up with a a hack to resolve this problem.