aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/doc/snippets/layouts/responsiveStates.qml
blob: 5506407230fd3101e68e37ca1ed51c9dbcc50f7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

import QtQuick
import QtQuick.Layouts
import QtQuick.Window

Window {
    visible: true
    width: 350
    height: 250
    //! [document]
    GridLayout {
        anchors.fill: parent

        Rectangle {
            id: rectangle1
            color: "tomato"
            Layout.fillHeight: true
            Layout.fillWidth: true
        }

        Rectangle {
            id: rectangle2
            color: "lightskyblue"
            Layout.fillHeight: true
            Layout.fillWidth: true
        }

        states: [
            State {
                when: width < 300
                PropertyChanges { target: rectangle2; Layout.row: 1 }
                PropertyChanges { target: rectangle2; Layout.column: 0 }
            },
            State {
                when: width >= 300
                PropertyChanges { target: rectangle2; Layout.row: 0 }
                PropertyChanges { target: rectangle2; Layout.column: 1 }
            }
        ]
    }
    //! [document]
}