Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. [Solved] Pure QML plugin as a single file (library)
Forum Updated to NodeBB v4.3 + New Features

[Solved] Pure QML plugin as a single file (library)

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    imihajlov
    wrote on last edited by
    #1

    Hello! Now I have another question about QML plugins. I have a lot of qml files which should be shared between several applications. We ship the applications to the customers, and we don't want them to see a lot of qml files. I used to put the files into the resources of the application, and it worked good. But now I want to detach the qml files to a plugin and make them available from different applications. I know there is a way to put the files into a directory and write a qmldir file to describe it, but it's not suitable because we don't want users to see the bare code.
    Is there a way to make a single file (a shared library or an archive) from the set of qml files and load it making the qml types available in the application?

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      You can simply load resources dynamically. Divide your QML into as many .qrc files, and load ones you need in your application (with QResource::registerResource()).

      (Z(:^

      1 Reply Last reply
      0
      • I Offline
        I Offline
        imihajlov
        wrote on last edited by
        #3

        OK, I've found the solution.

        Create new project as a static/dynamic library.

        Add the qml files to the project.

        Create a resource description with a custom prefix ('controls' for example), add there the qml files.

        Compile the library

        Add library import into the main application project's settings.

        Add resource initialization into the beginning of int main() of the application: @Q_INIT_RESOURCE_EXTERN(controls)

        Q_INIT_RESOURCE(controls); @

        Import library qml items by specifying the relative path:
        @
        import "../controls"@

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved