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 open one window from another with qml
Forum Updated to NodeBB v4.3 + New Features

how to open one window from another with qml

Scheduled Pinned Locked Moved Solved QML and Qt Quick
16 Posts 2 Posters 5.1k 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.
  • dheerendraD Offline
    dheerendraD Offline
    dheerendra
    Qt Champions 2022
    wrote on last edited by
    #6

    Assign the id property for the first window. Inside the handler you can say id.visible = false;

    Dheerendra
    @Community Service
    Certified Qt Specialist
    http://www.pthinks.com

    M 1 Reply Last reply
    1
    • dheerendraD dheerendra

      Assign the id property for the first window. Inside the handler you can say id.visible = false;

      M Offline
      M Offline
      Marito Mesquita
      wrote on last edited by
      #7

      @dheerendra realized now that the second window does not open as a new window , it opens inside the first window and when i give the command to set as false the first window visibility it closes both windows

      1 Reply Last reply
      0
      • dheerendraD Offline
        dheerendraD Offline
        dheerendra
        Qt Champions 2022
        wrote on last edited by
        #8

        show me the code change you have done.

        Dheerendra
        @Community Service
        Certified Qt Specialist
        http://www.pthinks.com

        1 Reply Last reply
        1
        • M Offline
          M Offline
          Marito Mesquita
          wrote on last edited by
          #9

          import QtQuick 2.9
          import QtQuick.Controls 2.4

          ApplicationWindow {

           id: lol
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
          
          Loader{
               id : ld
          }
          
          
          
          Frame {
          
              width: 300
              height: 400
              anchors.horizontalCenter: parent.horizontalCenter
              anchors.verticalCenter: parent.verticalCenter
          

          Column {
          anchors.horizontalCenter: parent.horizontalCenter;
          anchors.verticalCenter: parent.verticalCenter;

              spacing: 5;
          
              Label{
          
                  width: 200
                  height: 30
                anchors.horizontalCenter: Column.horizontalCenter;
                //anchors.verticalCenter: Column.verticalCenter
                  text: "FACEBOOK"
                  color: "black"
                  visible: true
              }
          
              TextField{
                  text: "username "
                  width: 200
                  height: 30
          
                  anchors.horizontalCenter: Column.horizontalCenter;
                  anchors.verticalCenter: Column.verticalCenter;
          
                  visible: true
          
          
          
              }
          
              TextField{
          
                  text: "password "
                  width: 200
                  height: 30
          
                  anchors.horizontalCenter: Column.horizontalCenter;
                  anchors.verticalCenter: Column.verticalCenter;
          
                  visible: true
          
              }
          
              Button{
          
                  width: 200
                  height: 30
                  anchors.horizontalCenter: Column.horizontalCenter;
                  anchors.verticalCenter: Column.verticalCenter;
          
                  text: "loggin"
                  visible: true
                  onClicked: {
                         console.log("Dheerendra Window Clicked")
          
                      ld.source = "page2.qml"
          
                      lol.visible = false
          
                  }
          
          
          
          
          
              }
          
          
          }
          

          }

          }

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Marito Mesquita
            wrote on last edited by
            #10

            ![alt text](0_1544948274860_Screenshot (48).png image url)

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #11

              After looking at this image I have question. Why do you want to show another windows ? Is it the error message you wanted to show ? if this the case you can show dialog.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              M 1 Reply Last reply
              1
              • dheerendraD Offline
                dheerendraD Offline
                dheerendra
                Qt Champions 2022
                wrote on last edited by dheerendra
                #12

                I tried with you code now. When I launch it starts the user/password window. When I click on log button, it closes user/pass windows and shows the new window. Can you show what is available in Page2.qml ? Is it starting from Window as root element ? Looks like your Page2.qml qml root is not Window. Confirm the same.

                Dheerendra
                @Community Service
                Certified Qt Specialist
                http://www.pthinks.com

                M 1 Reply Last reply
                1
                • dheerendraD dheerendra

                  After looking at this image I have question. Why do you want to show another windows ? Is it the error message you wanted to show ? if this the case you can show dialog.

                  M Offline
                  M Offline
                  Marito Mesquita
                  wrote on last edited by
                  #13

                  @dheerendra i wanted to open the program main window from the login button

                  1 Reply Last reply
                  0
                  • dheerendraD dheerendra

                    I tried with you code now. When I launch it starts the user/password window. When I click on log button, it closes user/pass windows and shows the new window. Can you show what is available in Page2.qml ? Is it starting from Window as root element ? Looks like your Page2.qml qml root is not Window. Confirm the same.

                    M Offline
                    M Offline
                    Marito Mesquita
                    wrote on last edited by
                    #14

                    @dheerendra it doesn't shows the new window to me.
                    yes the page 2 window is not starting as a root element

                    1 Reply Last reply
                    0
                    • M Offline
                      M Offline
                      Marito Mesquita
                      wrote on last edited by
                      #15

                      0_1544997188280_Screenshot (49).png

                      it shows this output

                      1 Reply Last reply
                      0
                      • M Offline
                        M Offline
                        Marito Mesquita
                        wrote on last edited by
                        #16

                        0_1544997982471_Screenshot (50).png
                        thank you sir , just made it , it opens the second window, i'm really grateful

                        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