Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Add c++ model to qml

    QML and Qt Quick
    qml c++ cmake
    1
    1
    164
    Loading More Posts
    • 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
      ppitu last edited by ppitu

      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 Reply Quote 0
      • First post
        Last post