DropDownColumn.qml 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. import QtQuick 2.9
  2. import QtQuick.Layouts 1.2
  3. Column {
  4. id: root
  5. property alias header: _headerText.text
  6. property alias value: _valueText.text
  7. default property alias content: _content.data
  8. anchors.left: parent.left
  9. anchors.right: parent.right
  10. state: "closed"
  11. states: [
  12. State {
  13. name: "opened"
  14. PropertyChanges {
  15. target: _content
  16. visible: true
  17. }
  18. PropertyChanges {
  19. target: _ddArrow
  20. rotation: 0
  21. }
  22. },
  23. State {
  24. name: "closed"
  25. PropertyChanges {
  26. target: _content
  27. visible: false
  28. }
  29. PropertyChanges {
  30. target: _ddArrow
  31. rotation: 180
  32. }
  33. }
  34. ]
  35. MouseArea {
  36. id: _header
  37. height: 70
  38. anchors.left: parent.left
  39. anchors.right: parent.right
  40. anchors.leftMargin: 10
  41. anchors.rightMargin: 10
  42. onClicked: {
  43. root.state = root.state == "closed" ? "opened" : "closed"
  44. }
  45. RowLayout {
  46. anchors.fill: parent
  47. PrimaryText {
  48. id: _headerText
  49. Layout.alignment: Qt.AlignLeft | Qt.AlignBottom
  50. }
  51. PrimaryText {
  52. id: _valueText
  53. Layout.alignment: Qt.AlignRight | Qt.AlignBottom
  54. Layout.rightMargin: 20
  55. }
  56. Image {
  57. id: _ddArrow
  58. source: "qrc:/images/arrow.png"
  59. Layout.alignment: Qt.AlignRight | Qt.AlignBottom
  60. Behavior on rotation {
  61. NumberAnimation { duration: 200 }
  62. }
  63. }
  64. }
  65. Rectangle {
  66. visible: false
  67. anchors.fill: parent
  68. color: "#66ff0000"
  69. }
  70. }
  71. Column {
  72. id: _content
  73. anchors.left: parent.left
  74. anchors.right: parent.right
  75. anchors.leftMargin: 30
  76. }
  77. }