Qt Forum

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

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

    QML and Qt Quick
    3
    4
    1664
    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.
    • V
      venkatesh88 last edited by

      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 Reply Quote 0
      • sierdzio
        sierdzio Moderators last edited by

        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 Reply Quote 4
        • ODБOï
          ODБOï last edited by ODБOï

          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 Reply Quote 2
          • V
            venkatesh88 @ODБOï last edited by

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

            thanks it's worked

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