Advertisement
Guest User

Untitled

a guest
Jun 9th, 2020
16
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. import QtQuick 2.12
  2. import QtQuick.Window 2.12
  3. import QtQuick.Controls 2.12
  4. import QtQuick.Controls.Material 2.12
  5. import Qt.labs.qmlmodels 1.0
  6. ApplicationWindow {
  7. id: root
  8. width: Screen.desktopAvailableWidth
  9. height: Screen.desktopAvailableHeight
  10. visible: true
  11. title: qsTr("TableView")
  12.  
  13. header: Rectangle {
  14. width: parent.width
  15. height: Screen.desktopAvailableHeight * 0.1
  16. color: Material.color(Material.LightBlue)
  17. }
  18. TableView {
  19. anchors.fill: parent
  20. rowHeightProvider: function (row) { return height/rows}
  21. columnWidthProvider: function (column) {return root.width/4}
  22. model: TableModel {
  23. id: tableModel
  24. rows: [
  25. {},
  26. {},
  27. {},
  28. {},
  29. {}
  30. ]
  31. TableModelColumn {}
  32. TableModelColumn {}
  33. TableModelColumn {}
  34. }
  35.  
  36. delegate: Rectangle {
  37. border.width: 1
  38. border.color: Material.color(Material.LightBlue)
  39. Text {
  40. anchors.centerIn: parent
  41. text: index
  42. }
  43. }
  44. Component.onCompleted: {
  45. for (var i = 0; i < 5;++i)
  46. tableModel.appendRow(i)
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement