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 load multiple files from main.qml ?
QtWS25 Last Chance

How to load multiple files from main.qml ?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
multiple fileswindowsqml filesseparate files
4 Posts 3 Posters 1.7k 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.
  • N Offline
    N Offline
    Natalya
    wrote on last edited by
    #1

    Hi everyone,

    I'm trying to create my first app, using qml, and I'm facing a wall :

    I want to create 2 windows, both are done but as the code is quite long for each of them in one file + the connections, I wanted to separate them in two files. But I don't know how to load "win1.qml" and "win2.qml" at start from my "main.qml" file, loaded by my "main.cpp". How can I do that ? I could'nt find anything working on the web yet :(

    Thanks for your help !

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      You should take a look at the RSS Feed QtQuick example. It uses several separated components within the same source tree.

      Hope it helps

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Natalya
        wrote on last edited by
        #3

        Hi SGaist, thanks a lot.

        I have found a solution in the meantime : I am using this and it works just fine ! (It takes few seconds to appear but I don't really care).
        Nonetheless thanks a lot for your answer, I will take a closer look at it to find a better way to do what I want.

        Here's how I managed to do my file separation :

        Timer{
            running: true
            repeat: false
            onTriggered: {
                var componentA = Qt.createComponent("driverWindow.qml")
                if (componentA.status === Component.Ready)
                    componentA.createObject(parent)
                var componentB = Qt.createComponent("graphsWindow.qml")
                if (componentB.status === Component.Ready)
                    componentB.createObject(parent)
            }
        }
        

        Have a good day !

        Pablo J. RoginaP 1 Reply Last reply
        0
        • N Natalya

          Hi SGaist, thanks a lot.

          I have found a solution in the meantime : I am using this and it works just fine ! (It takes few seconds to appear but I don't really care).
          Nonetheless thanks a lot for your answer, I will take a closer look at it to find a better way to do what I want.

          Here's how I managed to do my file separation :

          Timer{
              running: true
              repeat: false
              onTriggered: {
                  var componentA = Qt.createComponent("driverWindow.qml")
                  if (componentA.status === Component.Ready)
                      componentA.createObject(parent)
                  var componentB = Qt.createComponent("graphsWindow.qml")
                  if (componentB.status === Component.Ready)
                      componentB.createObject(parent)
              }
          }
          

          Have a good day !

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @Natalya if your issue is solved, please don't forget to mark your post as such. Thanks.

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          0

          • Login

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