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. [SOLVED] Trouble with import

[SOLVED] Trouble with import

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

    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

    p3c0P 1 Reply Last reply
    0
    • R 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

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

      Hi @RudolfVonKrugstein I have explained a similar one here.

      157

      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