aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquicktableview/data/positionlast.qml
blob: fcc2f34fae617c3221087dfb5931712e747d0635 (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
45
46
47
48
49
50
51
52
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick

Item {
    width: 300
    height: 300

    property alias tableView: tableView
    property bool positionOnRowsChanged: false
    property bool positionOnColumnsChanged: false
    property bool positionOnContentHeightChanged: false
    property bool positionOnContentWidthChanged: false

    TableView {
        id: tableView
        anchors.fill: parent
        clip: true

        delegate: Rectangle {
            implicitWidth: 100
            implicitHeight: 100
            Text {
                anchors.centerIn: parent
                text: "row:" + row + "\ncol:" + column
                font.pixelSize: 10
            }
        }

        onRowsChanged: {
            if (positionOnRowsChanged)
                positionViewAtRow(rows - 1, TableView.AlignBottom)
        }

        onColumnsChanged: {
            if (positionOnColumnsChanged)
                positionViewAtColumn(columns - 1, TableView.AlignRight)
        }

        onContentHeightChanged: {
            if (positionOnContentHeightChanged)
                positionViewAtRow(rows - 1, TableView.AlignBottom)
        }

        onContentWidthChanged: {
            if (positionOnContentWidthChanged)
                positionViewAtColumn(columns - 1, TableView.AlignRight)
        }
    }

}