Qt Forum

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

    Update: Forum Guidelines & Code of Conduct

    Unsolved Switching views using states and transition

    QML and Qt Quick
    4
    10
    909
    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
      vishu_fcb last edited by

      This post is deleted!
      1 Reply Last reply Reply Quote 0
      • ?
        A Former User last edited by

        Hi! Please be more specific.

        V 1 Reply Last reply Reply Quote 0
        • dheerendra
          dheerendra Qt Champions 2022 last edited by

          This is too generic question & requires complete tutorial on States & transition. Please read how states work from documentation. Try some example. If something does not work, post the question here.

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

          V 1 Reply Last reply Reply Quote 1
          • V
            vishu_fcb @Guest last edited by

            @Wieland Basically i have a main.qml and two other qml files .
            Default state will load my first qml over the main and when i press a button on the first qml , the second qml should overlap my first qml !!
            I tried using states and transitions but once i load my first qml , i am unable to load my second qml on the first qml ..
            I have tried ANCHORchange and Propertychange options but nothing worked

            1 Reply Last reply Reply Quote 0
            • ?
              A Former User last edited by

              Do you mean like this?

              Item {
                  id: item
                  width: 600
                  height: 400
              
                  Rectangle {
                      id: plumRect
                      anchors.left: item.left
                      width: 400
                      height: 400
                      color: "plum"
                      Button {
                          text: "plumRect to top"
                          onClicked: item.state = "plumRectOnTop"
              
                      }
                  }
              
                  Rectangle {
                      id: pinkRect
                      anchors.right: item.right
                      width: 400
                      height: 400
                      color: "pink"
                      Button {
                          anchors.right: pinkRect.right
                          text: "pinkRect to top"
                          onClicked: item.state = "" // default state
                      }
                  }
              
                  states: [
                      State {
                          name: "plumRectOnTop"
                          PropertyChanges { target: plumRect; z: pinkRect.z+1 }
                      }
                  ]
              }
              
              1 Reply Last reply Reply Quote 0
              • V
                vishu_fcb @dheerendra last edited by

                @dheerendra @Wieland Basically i have a main.qml and two other qml files .
                Default state will load my first qml over the main and when i press a button on the first qml , the second qml should overlap my first qml !!
                I tried using states and transitions but once i load my first qml , i am unable to load my second qml on the first qml ..
                I have tried ANCHORchange and Propertychange options but nothing worked

                1 Reply Last reply Reply Quote 0
                • dheerendra
                  dheerendra Qt Champions 2022 last edited by

                  Understood. Prepare the sample & post the code here. Then one of the forum person will help you.

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

                  1 Reply Last reply Reply Quote 1
                  • V
                    vishu_fcb last edited by A Former User

                    import QtQuick 2.5
                    import QtQuick.Window 2.2
                    
                    Window {
                        id:root
                        visible:true
                        width: 640
                        height: 480
                    //    flags: Qt.FramelessWindowHint | Qt.Window
                    
                     Rectangle{
                         id:base
                         width: root.width
                         height: root.height
                         state:Home
                    
                         Temp_selection {
                           id:main_window
                         }
                    
                         Menu_pop {
                             id:menu_disp
                             visible: false
                         }
                    
                         Status_line {
                            id:stauts_line_pointer
                         }
                    
                        states: [
                            State {
                                name: "Home"
                                AnchorChanges{
                                    target: main_window
                                    anchors.top:base.top
                                    anchors.bottom: base.bottom
                                }
                                PropertyChanges {
                                    target:main_window
                                    x: base.x
                                    y: base.y
                                }
                            },
                    
                            State {
                                name: "menu"
                    //            when: stauts_line_pointer.mouse_area.pressed
                                AnchorChanges{
                                    target: menu_disp
                                    anchors.right:main_window.right
                                    anchors.bottom: main_window.bottom
                                }
                                PropertyChanges {
                                    target:menu_disp
                                    x: base.x
                                    y: base.y
                                    visible:true
                    
                                }
                            }
                    ]
                        transitions: [
                            Transition {
                                from: "Home"
                                to: "menu"
                                NumberAnimation { properties: "x,y"; easing.type: Easing.InOutQuad }
                                AnchorAnimation { duration: 800; easing.type: Easing.InOutBack; easing.overshoot: 2 }
                    //          PropertyAnimation{ property: x; duration: 1000}
                    //          PropertyAnimation{ property: y; duration: 1000}
                    //           ColorAnimation { duration: 3000}
                            }
                        ]
                    }
                    }
                    

                    My second state transition i.e from HOME to MENU is not taking place .

                    [Edit: Added code tags -- @Wieland]

                    1 Reply Last reply Reply Quote 0
                    • Yashpal
                      Yashpal last edited by

                      @vishu_fcb Make sure this statement <when: stauts_line_pointer.mouse_area.pressed> is proper. You can use children property of 'stauts_line_pointer' to access mousearea, if the later is the child of 'stauts_line_pointer'. Also, state:Home should be <state : "Home"> in base Rectangle.

                      V 1 Reply Last reply Reply Quote 2
                      • V
                        vishu_fcb @Yashpal last edited by

                        @Yashpal Thanks ! i ll surely give it a shot

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