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 path to qml file?
QtWS25 Last Chance

How to specify path to qml file?

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

    Hello citizens!
    By default an app searches files in the build directory, so I have to write

    QQuickView viewer; 
    viewer.setSource(QUrl("../QML-graph/Main.qml"));
    

    to load qml file. Is it OK to specify such "../" path or there is a better way to set the path?

    In the Cmake I added qml files in this way:

    qt_add_qml_module(appQML-graph
        URI QML-graph
        VERSION 1.0
        QML_FILES
            "Main.qml"
            "serialport-view.qml"
    
    1 Reply Last reply
    0
    • A Offline
      A Offline
      aran
      wrote on last edited by
      #2

      After adding them with qt_add_qml_module they should all be available as resource:

      QQuickView viewer; 
      viewer.setSource(QUrl("qrc:/QML-graph/Main.qml"));
      
      Atr0p0sA 1 Reply Last reply
      1
      • A aran

        After adding them with qt_add_qml_module they should all be available as resource:

        QQuickView viewer; 
        viewer.setSource(QUrl("qrc:/QML-graph/Main.qml"));
        
        Atr0p0sA Offline
        Atr0p0sA Offline
        Atr0p0s
        wrote on last edited by
        #3

        @aran thanks :)

        1 Reply Last reply
        0
        • Atr0p0sA Atr0p0s has marked this topic as solved on

        • Login

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