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 make QML applications with multiple files using the same technique as is done with Qt and Widgets?

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

Scheduled Pinned Locked Moved QML and Qt Quick
7 Posts 4 Posters 5.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.
  • F Offline
    F Offline
    flaviomarcio
    wrote on last edited by
    #1

    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
    0
    • B Offline
      B Offline
      Beberd
      wrote on last edited by
      #2

      You can use Item and a Loader

      1 Reply Last reply
      0
      • F Offline
        F Offline
        flaviomarcio
        wrote on last edited by
        #3

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

        Flavio Portela

        1 Reply Last reply
        0
        • B Offline
          B Offline
          Beberd
          wrote on last edited by
          #4

          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
          0
          • C Offline
            C Offline
            chrisadams
            wrote on last edited by
            #5

            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
            0
            • U Offline
              U Offline
              utcenter
              wrote on last edited by
              #6

              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
              0
              • F Offline
                F Offline
                flaviomarcio
                wrote on last edited by
                #7

                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
                0

                • Login

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