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. Add c++ model to qml
Forum Updated to NodeBB v4.3 + New Features

Add c++ model to qml

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlc++cmake
1 Posts 1 Posters 292 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.
  • P Offline
    P Offline
    ppitu
    wrote on last edited by ppitu
    #1

    Hi,
    I create c++ model as library and I want to add it to my qml app.
    I have following project structure:

    A/
    CMakeLists.txt
    - mylib/
    - CMakeLists.txt
    - - model/
    - - CMakeLists.txt
    - app/
    - CMakeLists.txt
    - main.qml
    

    So I want to import class from model (A/mylib/model) to main.qml. I try use:

    qt6_add_qml_module(model
        URI mylib.model
        VERSION 1.0
        SOURCES
            someclass.h someclass.cc
    )
    

    In CMakeLists.txt in model dir.
    And I import this to main.qml:

    import mylib.model
    

    But when I start problem I receive:

    module "mylib.model" is not installed
    

    How should I adopt my cmake files to work with this model in main.qml?

    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