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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
import QtQuick 2.14
import QtQuick.Window 2.3
Item {
width: 640
height: 450
property alias tableView: mainTableView
property alias tableViewH: tableViewH
property alias tableViewV: tableViewV
property alias tableViewHV: tableViewHV
property real delegateWidth: 30
property real delegateHeight: 60
Column {
spacing: 10
TableView {
id: tableViewH
objectName: "Hor"
width: 600
height: 100
anchors.margins: 1
clip: true
delegate: tableViewDelegate
syncView: mainTableView
syncDirection: Qt.Horizontal
}
TableView {
id: tableViewV
objectName: "Ver"
width: 600
height: 100
anchors.margins: 1
clip: true
delegate: tableViewDelegate
syncView: mainTableView
syncDirection: Qt.Vertical
}
TableView {
id: tableViewHV
objectName: "HorVer"
width: 600
height: 100
anchors.margins: 1
clip: true
delegate: tableViewDelegate
syncView: mainTableView
}
TableView {
id: mainTableView
objectName: "root"
width: 600
height: 100
anchors.margins: 1
clip: true
delegate: tableViewDelegateMainView
columnSpacing: 1
rowSpacing: 1
columnWidthProvider: function(c) { return 50 + c }
rowHeightProvider: function(r) { return 25 + r }
}
}
Component {
id: tableViewDelegate
Rectangle {
objectName: "tableViewDelegate"
color: "lightblue"
border.width: 1
implicitWidth: 100
implicitHeight: 100
Text {
anchors.centerIn: parent
font.pixelSize: 10
text: parent.TableView.view.objectName + "\n" + column + ", " + row
}
}
}
Component {
id: tableViewDelegateMainView
Rectangle {
objectName: "tableViewDelegate"
color: "lightgray"
border.width: 1
implicitWidth: delegateWidth
implicitHeight: delegateHeight
Text {
anchors.centerIn: parent
font.pixelSize: 10
text: parent.TableView.view.objectName + "\n" + column + ", " + row
}
}
}
}
|