CustomComboBox.qml 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import Felgo 4.0
  2. import QtQuick 2.5
  3. import QtQuick.Controls 2.0
  4. ComboBox {
  5. id: comboBox
  6. implicitWidth: dp(90)// + 20
  7. implicitHeight: dp(24)// + topPadding + bottomPadding
  8. padding: dp(12)
  9. // overwrite style for density independent sizes
  10. delegate: ItemDelegate {
  11. width: comboBox.implicitWidth
  12. height: comboBox.implicitHeight
  13. padding: dp(12)
  14. contentItem: AppText {
  15. text: modelData
  16. color: highlighted ? Theme.tintColor : Theme.textColor
  17. wrapMode: Text.NoWrap
  18. }
  19. background: Rectangle {
  20. color: Theme.backgroundColor
  21. }
  22. highlighted: comboBox.highlightedIndex == index
  23. }
  24. popup: Popup {
  25. width: comboBox.width
  26. y: comboBox.height - 1
  27. implicitHeight: contentItem.implicitHeight
  28. padding: 1
  29. contentItem: ListView {
  30. clip: true
  31. implicitHeight: contentHeight
  32. model: comboBox.popup.visible ? comboBox.delegateModel : null
  33. currentIndex: comboBox.highlightedIndex
  34. }
  35. background: Rectangle {
  36. color: Theme.backgroundColor
  37. border.color: Theme.textColor
  38. border.width: dp(1)
  39. radius: 2
  40. }
  41. }
  42. contentItem: AppText {
  43. width: comboBox.width - (comboBox.indicator ? comboBox.indicator.width : 0) - comboBox.spacing
  44. text: comboBox.displayText
  45. wrapMode: Text.NoWrap
  46. }
  47. }