Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Organising a QML project with a plugin and an app
Acristal last edited by Acristal
I had a question about the organisation of my project with QML (I use Qt 5.3.2).
I have a set of standard/generic controls that I want to use to build an actual application.
What I wanted to do is to have a specific QML plugin with all my controls, and then use that plugin on my application.
Does that make sense? I have a hard time finding out ways of organising a QML project online.
So I tried to implement this system, and I end up with this: my main project is a template subdirs project. It has 2 children:
controlsis the QML plugin (template lib), and
appis the application itself (template app).
controlsproject, I have a
qmldirfile to register my plugin and my QML files. All the resources of my plugin (QML files and icons) are in the QRC of
controls. The install step only copy the dynamic library (which I think should contain the QRC) and the
qmldir. I used a QRC because I'd really like to only have a dynamic library and not have to publish all the QML sources.
appproject, I also have a QRC with the actual views of my application. This project has no direct link with the
controlsproject, since the latter generated a dynamic library.
The entire thing look like this:
root/ | +-- root.pro | +-- app/ | | | +-- app.pro | | | +-- app.qrc/ | | | +-- main.qml | +-- controls/ | +-- controls.pro | +-- qmldir | +-- controls.qrc/ | +-- QML + icons...
When I run my application, I specify the
QML2_IMPORT_PATHto the path where I installed the
controlsplugin so that I can
import my.plugin.controls 1.0in my views.
But, the issue is that, although my application find the plugin, it can not load the QML elements because the files are not found.
I tried to use
Q_INIT_RESOURCE(controls)in the app, but it doesn't work either. I always end up with my QML files being not found.
How can I fix that? Is this an idiomatic way of organising a QML project in the first place?
Thanks a lot!