VerticalHeaderView.qml 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2021 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the Qt Quick Controls 2 module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:COMM$
  9. **
  10. ** Commercial License Usage
  11. ** Licensees holding valid commercial Qt licenses may use this file in
  12. ** accordance with the commercial license agreement provided with the
  13. ** Software or, alternatively, in accordance with the terms contained in
  14. ** a written agreement between you and The Qt Company. For licensing terms
  15. ** and conditions see https://www.qt.io/terms-conditions. For further
  16. ** information use the contact form at https://www.qt.io/contact-us.
  17. **
  18. ** $QT_END_LICENSE$
  19. **
  20. **
  21. **
  22. **
  23. **
  24. **
  25. **
  26. **
  27. **
  28. **
  29. **
  30. **
  31. **
  32. **
  33. **
  34. **
  35. ****************************************************************************/
  36. import QtQuick 2.15
  37. import QtQuick.Controls 2.15
  38. import QtQuick.Templates 2.15 as T
  39. T.VerticalHeaderView {
  40. id: control
  41. implicitWidth: contentWidth
  42. implicitHeight: syncView ? syncView.height : 0
  43. delegate: Rectangle {
  44. // Qt6: add cellPadding (and font etc) as public API in headerview
  45. readonly property real cellPadding: 8
  46. implicitWidth: Math.max(control.width, text.implicitWidth + (cellPadding * 2))
  47. implicitHeight: text.implicitHeight + (cellPadding * 2)
  48. color: "#f6f6f6"
  49. border.color: "#e4e4e4"
  50. Text {
  51. id: text
  52. text: control.textRole ? (Array.isArray(control.model) ? modelData[control.textRole]
  53. : model[control.textRole])
  54. : modelData
  55. width: parent.width
  56. height: parent.height
  57. horizontalAlignment: Text.AlignHCenter
  58. verticalAlignment: Text.AlignVCenter
  59. color: "#ff26282a"
  60. }
  61. }
  62. }