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. Installing a reusable QML module
Forum Updated to NodeBB v4.3 + New Features

Installing a reusable QML module

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 74 Views
  • 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.
  • T Offline
    T Offline
    Thiesius
    wrote on last edited by
    #1

    Hello,

    I'm looking for some guidance on how to create a reusable QML module with CMake.

    So let's say I want to create a module "MyReusableThing" that would have a few cpp files marked with QML_ELEMENT and several reusable .qml components.
    As I understand I will get a "backing" library, plugin library, qmldir and .qmltypes.
    So I start by calling

    qt_add_qml_module(MyReusableThing SHARED
        URI "MyReusableThing"
        RESOURCE_PREFIX "/"
        SOURCES a.cpp b.cpp # etc.
        QML_FILES Comp1.qml Comp2.qml # etc.
      )
    

    How should I then proceed to create an "installation"?
    E.g. I install it to D:/libs/MyReusableThing/
    Where I would expect to find something like:

    lib/MyReusableThing.dll
    cmake/...
    

    and then I also expect I can see something similar to what one can find in Qt install dir:

    qml/MyReusableThing/qmldir
    qml/MyReusableThing/MyReusableThingplugin.dll
    qml/MyReusableThing/MyReusableThing.qmltypes
    qml/MyReusableThing/Comp1.qml
    qml/MyReusableThing/Comp2.qml
    

    The goal I want to achieve is to create new CMake project that would consume this "library". So then I think I would add
    D:/libs/MyReusableThing/qml/ to QML_IMPORT_PATH and D:/libs/MyReusableThing/ to my CMAKE_PREFIX_PATH

    And in the consuming module I would just write
    find_package(MyReusableThing REQUIRED CONFIG)
    and link MyReusableThing::MyReusableThing to the app (backing library?)

    In my QML files I would presumably just use Comp1 and Comp2 and the deploy script would take care of the rest. To copy them to the "deploy" dir.

    How can I achieve this, or what is an "official" way of doing things like this? When I search the internet I always find self-contained monolithic projects.

    Thank you for insights :)

    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