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. Load qml file from outside of qml.qrc
Forum Updated to NodeBB v4.3 + New Features

Load qml file from outside of qml.qrc

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 3.1k Views 2 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.
  • Chris_1981C Offline
    Chris_1981C Offline
    Chris_1981
    wrote on last edited by
    #1

    I want to load a qml file ('main.qml') which resides outside of the qml.qrc resource. How do I do that?
    Project structure:

    Resources
      qml.qrc
        / 
          main.qml
      QML
        view.qml
    

    main.qml:

    import QtQuick 2.5
    import QtQuick.Window 2.2
    
    Window {
      visible: true
      Loader {
        id: loader
        source: "view.qml"; // qrc:/view.qml: File not found
      }
    }
    

    Note: I already tried this: How to Locally Disable QRC in QML but it seams that 'baseUrl' is not set.

    p3c0P 1 Reply Last reply
    0
    • Chris_1981C Chris_1981

      I want to load a qml file ('main.qml') which resides outside of the qml.qrc resource. How do I do that?
      Project structure:

      Resources
        qml.qrc
          / 
            main.qml
        QML
          view.qml
      

      main.qml:

      import QtQuick 2.5
      import QtQuick.Window 2.2
      
      Window {
        visible: true
        Loader {
          id: loader
          source: "view.qml"; // qrc:/view.qml: File not found
        }
      }
      

      Note: I already tried this: How to Locally Disable QRC in QML but it seams that 'baseUrl' is not set.

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi @Chris_1981
      Check if this help you.

      157

      1 Reply Last reply
      0
      • Chris_1981C Offline
        Chris_1981C Offline
        Chris_1981
        wrote on last edited by
        #3

        Thanks, p3c0, it works with the full path to the local file with file:/// in front!
        source: "file:///C://Users//Admin//Documents//LoaderDemo//view.qml";

        p3c0P 1 Reply Last reply
        0
        • Chris_1981C Chris_1981

          Thanks, p3c0, it works with the full path to the local file with file:/// in front!
          source: "file:///C://Users//Admin//Documents//LoaderDemo//view.qml";

          p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          @Chris_1981 But the you will have to put this whole path string whereever your require the Components it contains. Instead do and import once and just use the Component.

          157

          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