Organising a QML project with a plugin and an app



  • Hi guys!

    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: app and controls.
    controls is the QML plugin (template lib), and app is the application itself (template app).
    In the controls project, I have a qmldir file 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.
    In the app project, I also have a QRC with the actual views of my application. This project has no direct link with the controls project, 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_PATH to the path where I installed the controls plugin so that I can import my.plugin.controls 1.0 in 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!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.