Qt Forum

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

    Call for Presentations - Qt World Summit

    How to make QML applications with multiple files using the same technique as is done with Qt and Widgets?

    QML and Qt Quick
    4
    7
    5064
    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.
    • F
      flaviomarcio last edited by

      How to make QML applications with multiple files using the same technique as is done with Qt and Widgets?

      I would like to create muitiplas windows to feed a small database as user settings and configurations. but do not know to show in another QML file.

      I am not referring to custom controls like buttons and text ...

      eg

      main.qml

      menu.qml
      newuser.qml
      systemsettings.qml
      about.qml

      Flavio Portela

      1 Reply Last reply Reply Quote 0
      • B
        Beberd last edited by

        You can use Item and a Loader

        1 Reply Last reply Reply Quote 0
        • F
          flaviomarcio last edited by

          you can offer me more than that I'm still in the dark

          Flavio Portela

          1 Reply Last reply Reply Quote 0
          • B
            Beberd last edited by

            I think this page should help you.
            "QML Loader Element":http://harmattan-dev.nokia.com/docs/library/html/qt4/qml-loader.html

            1 Reply Last reply Reply Quote 0
            • C
              chrisadams last edited by

              Hi,

              From a "basic" point of view, each QML file defines a type, and if that type happens to be a visual item with some set dimensions (say, 500x500pix) then you can simply instantiate each one, and set the visible property of each appropriately.

              @
              //main.qml
              Item {
              width: 500
              height: 500

              MyPageOne { // defined in MyPageOne.qml
                  id: p1
                  anchors.fill: parent
                  visible: true
              }
              
              MyPageTwo { // defined in MyPageTwo.qml
                  id: p2
                  anchors.fill: parent
                  visible: false
              }
              
              // then on some event like a button click or whatever...
              function switchView() {
                  p1.visible: false
                  p2.visible: true
              }
              

              }
              @

              From a "higher level" point of view, most component sets / controls offer the "page stack" and "page" types. You define your types as Page-derived types, and then push/pop pages on/off the pagestack to perform UI navigation.

              There are plenty of examples on the web of this, since it was common in Harmattan for example.

              Cheers,
              Chris.

              1 Reply Last reply Reply Quote 0
              • U
                utcenter last edited by

                Unlike in C/C++ you don't need to include or import other QML files that are part of your project. You just need to add the extra QML files and you can directly use them as components, since each QML file can only have one root component.

                This is not the case with JS files, you still have to import them. Also the same goes for custom C++ components.

                1 Reply Last reply Reply Quote 0
                • F
                  flaviomarcio last edited by

                  OK, thanks for the replies.

                  I make large applications, I will not do something great with QML, but will not be small. will have many of user interface screens, maybe 30 ~ 50.

                  do not want heavy application.

                  Will it consume too much CPU or Memory or will it take to start?

                  Flavio Portela

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