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 import multiple qml files in to main.qml file
Forum Update on Monday, May 27th 2025

how to import multiple qml files in to main.qml file

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
4 Posts 3 Posters 2.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.
  • V Offline
    V Offline
    venkatesh88
    wrote on 5 Nov 2018, 09:57 last edited by
    #1

    i am new to qt qml , i just created one file with name of com1.qml in the same directory of the main.qml . In main qml i am importing the file using import "com1.qml" ,but it is throwing the error as QQmlApplicationEngine failed to load component
    qrc:/main.qml:4 "comp1.qml": no such directory

    can any please help?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 5 Nov 2018, 10:04 last edited by
      #2

      Component names must start with capital letter. Rename your file to Com1.qml. If it is in the same directory as main.qml, you don't need to import it. Just use it in main like this:

      Com1 {
      }
      

      (Z(:^

      1 Reply Last reply
      4
      • O Offline
        O Offline
        ODБOï
        wrote on 5 Nov 2018, 10:05 last edited by ODБOï 11 May 2018, 10:15
        #3

        Hi @venkatesh88,
        Your custom component name should start with uppercase letter
        // Comp1.qml
        you don't need any import statement if your components are in the same dir, use them directly in the main.qml

        Comp1{}
        

        http://doc.qt.io/qt-5/qml-qtqml-component.html

        V 1 Reply Last reply 5 Nov 2018, 10:25
        2
        • O ODБOï
          5 Nov 2018, 10:05

          Hi @venkatesh88,
          Your custom component name should start with uppercase letter
          // Comp1.qml
          you don't need any import statement if your components are in the same dir, use them directly in the main.qml

          Comp1{}
          

          http://doc.qt.io/qt-5/qml-qtqml-component.html

          V Offline
          V Offline
          venkatesh88
          wrote on 5 Nov 2018, 10:25 last edited by
          #4

          @LeLev said in how to import multiple qml files in to main.qml file:

          thanks it's worked

          1 Reply Last reply
          0

          4/4

          5 Nov 2018, 10:25

          • Login

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