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. qrc:/main.qml:9 "gui/delegates/UePeopleItemDelegate.qml": no such directory error

qrc:/main.qml:9 "gui/delegates/UePeopleItemDelegate.qml": no such directory error

Scheduled Pinned Locked Moved QML and Qt Quick
qmlimport
2 Posts 2 Posters 3.6k 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.
  • M Offline
    M Offline
    MarkoSan
    wrote on 10 Aug 2015, 07:02 last edited by p3c0 8 Nov 2015, 06:04
    #1

    I have a Qt Creator project (Qt/QML) that resided in /home/markofr/projects/ueBlagajnaClient. Now, inside this project I have following structure:Project files structure. Now, if I try to import UePeopleItemDelegate.qml int main.qml as in following code:

    import QtQuick 2.4
    import QtQuick.Controls 1.3
    import QtQuick.Window 2.2
    import QtQuick.Dialogs 1.2
    import QtMultimedia 5.0
    import QtQuick.Layouts 1.0
    import QtTest 1.1
    
    import "gui/delegates/UePeopleItemDelegate.qml" as UePersonItemDelegate
    
    ApplicationWindow
    {
        id: ueWindowMain
    
        title: qsTr("TestApp")
    
        width: 512//Screen.desktopAvailableWidth
        height: 512//Screen.desktopAvailableWidth
    
        visible: true
    
        opacity: 1.0
    
        contentOrientation: Qt.LandscapeOrientation
    
        color: "black"
    
        ListView {
            id: uePeopleListView
            snapMode: ListView.SnapToItem
            highlightRangeMode: ListView.ApplyRange
            anchors.right: parent.right
            anchors.rightMargin: 0
            anchors.bottom: parent.top
            anchors.bottomMargin: -128
            anchors.left: parent.left
            anchors.leftMargin: 0
            anchors.top: parent.top
            anchors.topMargin: 0
            orientation: ListView.Horizontal
            flickableDirection: Flickable.HorizontalFlick
            antialiasing: true
            delegate: UePersonItemDelegate
            model: ListModel {
                ListElement {
                    name: "Grey"
                    colorCode: "grey"
                }
    
                ListElement {
                    name: "Red"
                    colorCode: "red"
                }
    
                ListElement {
                    name: "Blue"
                    colorCode: "blue"
                }
    
                ListElement {
                    name: "Green"
                    colorCode: "green"
                }
            }
        }
    }
    

    Now, when I run this app, I get following error (in runtime, the code compiles and builds without problems):
    qrc:/main.qml:9 "gui/delegates/UePeopleItemDelegate.qml": no such directory
    How do I correctly import custom qml?

    P 1 Reply Last reply 11 Aug 2015, 06:13
    0
    • M MarkoSan
      10 Aug 2015, 07:02

      I have a Qt Creator project (Qt/QML) that resided in /home/markofr/projects/ueBlagajnaClient. Now, inside this project I have following structure:Project files structure. Now, if I try to import UePeopleItemDelegate.qml int main.qml as in following code:

      import QtQuick 2.4
      import QtQuick.Controls 1.3
      import QtQuick.Window 2.2
      import QtQuick.Dialogs 1.2
      import QtMultimedia 5.0
      import QtQuick.Layouts 1.0
      import QtTest 1.1
      
      import "gui/delegates/UePeopleItemDelegate.qml" as UePersonItemDelegate
      
      ApplicationWindow
      {
          id: ueWindowMain
      
          title: qsTr("TestApp")
      
          width: 512//Screen.desktopAvailableWidth
          height: 512//Screen.desktopAvailableWidth
      
          visible: true
      
          opacity: 1.0
      
          contentOrientation: Qt.LandscapeOrientation
      
          color: "black"
      
          ListView {
              id: uePeopleListView
              snapMode: ListView.SnapToItem
              highlightRangeMode: ListView.ApplyRange
              anchors.right: parent.right
              anchors.rightMargin: 0
              anchors.bottom: parent.top
              anchors.bottomMargin: -128
              anchors.left: parent.left
              anchors.leftMargin: 0
              anchors.top: parent.top
              anchors.topMargin: 0
              orientation: ListView.Horizontal
              flickableDirection: Flickable.HorizontalFlick
              antialiasing: true
              delegate: UePersonItemDelegate
              model: ListModel {
                  ListElement {
                      name: "Grey"
                      colorCode: "grey"
                  }
      
                  ListElement {
                      name: "Red"
                      colorCode: "red"
                  }
      
                  ListElement {
                      name: "Blue"
                      colorCode: "blue"
                  }
      
                  ListElement {
                      name: "Green"
                      colorCode: "green"
                  }
              }
          }
      }
      

      Now, when I run this app, I get following error (in runtime, the code compiles and builds without problems):
      qrc:/main.qml:9 "gui/delegates/UePeopleItemDelegate.qml": no such directory
      How do I correctly import custom qml?

      P Offline
      P Offline
      p3c0
      Moderators
      wrote on 11 Aug 2015, 06:13 last edited by
      #2

      @MarkoSan Following are the 2 ways to do it correctly,

      • If loading main.qml from resource (i.e qrc)
        for eg. engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        You will need to add the complete path so that the main.qml file in qrc is able to find it. For eg.

        import "file:///home/someusername/gui/delegates" //import using complete path
        UePeopleItemDelegate {  //using the loaded Component
        }
        
      • If loading main.qml directly i.e from some local path
        for eg. engine.load(QUrl(QStringLiteral("main.qml"))). Note no qrc
        Here you can use the relative path in main.qml

        import "./gui/delegates" //import using relative path
        UePeopleItemDelegate {  //using the loaded Component
        }
        

        Assuming the directory gui is present in same location that of main.qml as we have used "."

      157

      1 Reply Last reply
      2

      2/2

      11 Aug 2015, 06:13

      • Login

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