[Interest] Registering .pragma library files in custom QML plugins
izowiuz at gmail.com
Sat Jul 13 12:03:18 CEST 2019
My question is essentially something I already asked about on Qt's forums sometime in 2018:
We set the requirements such as:
- project is an application which usues a bunch of my custom QML plugins
- plugins contains custom .qml components, QQuickItem-based components, .js '.pragma library' components and all the other necessary stuff
- we want to 'properly' structure QML plugins
Currently, for a plugin called IzLibrary, I do:
- I register all my custom types / components using qmlRegisterType() functions in my QQmlExtensionPlugin subclass
- I enable qmlcachegen to precompile QML stuff to binary stuff
- I provide qmldir file with contents to:
// QMLDIR FILE START
IzToast 1.0 qrc:///include/IzLibrary/JS/IzToast.js
IzMark 1.0 qrc:///include/IzLibrary/JS/IzMark.js
IzBusy 1.0 qrc:///include/IzLibrary/JS/IzBusy.js
IzObjectCreator 1.0 qrc:///include/IzLibrary/JS/IzObjectCreator.js
// QMLDIR FILE END
- finally, using custom CMake commands, I generate .qmltypes file for syntax highlighting for my custom components and deploy all of this to the plugin's destination
Now, the problem. I'm not able to preregister my .js .pragam library files without 'IzMark 1.0 qrc:///include/IzLibrary/JS/IzMark.js' stuff in qmldir file.
I got this idea from Simon Hausmann, from his comment in this QTBUG:
"The suggested workaround of specifying a qrc path in the qmldir file is indeed one perfectly fine way of solving this.
Another option - the path chosen by QtQuick Controls - is to not list all of the components in the qmldir file but rather register them via qmlRegisterType() API calls in the plugin's initialization - then using a qrc path as well."
Which is working fine currently but, as described by Ulf Hermann, is considered bad practice and actually generates warnings when loading such plugins:
qmlRegisterType(QUrl(QStringLiteral("qrc:/include/IzLibrary/JS/IzBusy.js")), uri, 1, 0, "IzBusy");
crashes qmlplugindump during .qmltypes file generation and running my application with such a plugin crashes it also.
So my questions are. Have I missed something silly? Do I have to register .js files somewhat differently? Is this is currently possible to do?
Mentor, guru, bastion of modesty.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Interest