Advertisement
Guest User

Untitled

a guest
May 30th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. import QtQuick 2.2
  2. import QtQuick.Layouts 1.3
  3. import org.kde.kirigami 2.1 as Kirigami
  4.  
  5. GridView {
  6. id: view
  7. width: 500
  8. height: 500
  9.  
  10. property int iconSize: Kirigami.Units.iconSizes.large
  11.  
  12. //this checks how many columns fit that are as large as icon size, + margins on the sides
  13. cellWidth: width / Math.floor(width / (iconSize + Kirigami.Units.largeSpacing*2))
  14. //size of icon + height of labels(will need 2 lines) + a spacing, top and bottom
  15. cellHeight: iconSize + Kirigami.Units.gridUnit + Kirigami.Units.largeSpacing*2
  16.  
  17.  
  18. model: 20
  19. delegate: Item {
  20. width: view.cellWidth
  21. height: view.cellHeight
  22. ColumnLayout {
  23. anchors {
  24. left: parent.left
  25. right: parent.right
  26. top: parent.top
  27. topMargin: Kirigami.Units.largeSpacing
  28. }
  29. height: cellHeight
  30. Rectangle {
  31. Layout.alignment: Qt.AlignHCenter
  32. color: "red"
  33. width: view.iconSize
  34. height: width
  35. }
  36. Kirigami.Label {
  37. //TODO: multiline, text elide etc
  38. Layout.alignment: Qt.AlignHCenter
  39. text: "Text label"
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement