-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.qml
71 lines (56 loc) · 1.88 KB
/
main.qml
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
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.4
Window {
visible: true
width: 640
height: 480
title: qsTr("QSqlQueryModel - TableView")
// Uncomment this, if you want to call query from qml
// If you uncomment this, remember to comment out the followin line in main.cpp
// mysqlModel.callSql("SELECT * FROM users");
// Component.onCompleted: {
// MysqlModel.callSql("SELECT * FROM users")
// }
TableView {
id: tableView
columnWidthProvider: function (column) { return 100; }
rowHeightProvider: function (column) { return 60; }
anchors.fill: parent
ScrollBar.horizontal: ScrollBar{}
ScrollBar.vertical: ScrollBar{}
clip: true
model: MysqlModel
// Table Body
delegate: Rectangle {
Text {
text: display // This is set in mysqlmodel.cpp roleNames()
anchors.fill: parent
anchors.margins: 10
color: 'black'
font.pixelSize: 15
verticalAlignment: Text.AlignVCenter
}
}
// Table Header
Row {
id: columnsHeader
y: tableView.contentY
z: 2
Repeater {
model: tableView.columns > 0 ? tableView.columns : 1
Label {
width: tableView.columnWidthProvider(modelData)
height: 35
text: MysqlModel.headerData(modelData, Qt.Horizontal)
font.pixelSize: 15
padding: 10
verticalAlignment: Text.AlignVCenter
background: Rectangle { color: "#ccc" }
}
}
}
ScrollIndicator.horizontal: ScrollIndicator { }
ScrollIndicator.vertical: ScrollIndicator { }
}
}