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. how to specify new QML module in CMakeLists.txt?
Forum Updated to NodeBB v4.3 + New Features

how to specify new QML module in CMakeLists.txt?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 395 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.
  • mzimmersM Offline
    mzimmersM Offline
    mzimmers
    wrote on last edited by mzimmers
    #1

    Hi all -

    I want to include some QML files from another project (this one). The author built it as a demo executable, and I don't need most of his code; I just want to use a few of his .qml files.

    I've added this statement to my main.qml file:

    import "CircularSlider"
    

    I've also tried this:

    import "../CircularSlider"
    

    At runtime, I get an error "no such directory." Do I need to add something to my CMakeLists.txt file to make the directory visible to the program at runtime?

    Thanks...

    EDIT: I added this line into my qt_add_qml_module directive:

        CircularSlider/controls/CircularSlider.qml
    

    Seems to work OK now. Before I close this topic, though, I'd appreciate some feedback as to whether this is a good approach. As my project grows, should I just use the file system to group things, and create what will eventually become a rather large qt_add_qml_module() statement, or is there a preferred way? I notice the author of the code I'm using used a .qrc file for this purpose. I suppose this keeps the qmakelists.txt file compact; is that the primary benefit here?

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      This is right approach. You can refer

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      1

      • Login

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