Qt Forum

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

    [SOLVED] Trouble with import

    QML and Qt Quick
    2
    2
    387
    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.
    • R
      RudolfVonKrugstein last edited by RudolfVonKrugstein

      Hey,

      I am trying to put my qml files into directories. But for some reason the imports do not work during runtime (qt creator has not trouble finding the types). Here is a minimal example:

      qml.qrc:

      <RCC>
          <qresource prefix="/">
              <file>main.qml</file>
          </qresource>
          <qresource prefix="/area">
              <file>area/Area.qml</file>
          </qresource>
      </RCC>
      

      main.qml:

      import QtQuick 2.5
      import QtQuick.Window 2.2
      
      import "area"
      
      Window {
          visible: true
          Area {}
      }
      

      area/Area.qml:

      import QtQuick 2.0
      
      Rectangle {
          anchors.fill: parent
          MouseArea {
              anchors.fill: parent
              onClicked: {
                  Qt.quit();
              }
          }
      }
      

      The error (during runtime) is:

      QQmlApplicationEngine failed to load component
      qrc:/main.qml:8 Area is not a type
      

      Why is Area not found?

      Thanks!
      Nathan

      p3c0 1 Reply Last reply Reply Quote 0
      • p3c0
        p3c0 Moderators @RudolfVonKrugstein last edited by

        Hi @RudolfVonKrugstein I have explained a similar one here.

        157

        1 Reply Last reply Reply Quote 1
        • First post
          Last post