UserRadioButton.qml 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import QtQuick 2.12
  2. import QtQuick.Controls 2.12
  3. //自定义单选按钮
  4. RadioButton {
  5. id: control
  6. text: qsTr("UserRadioButton")
  7. checked: true
  8. indicator: Rectangle {
  9. implicitWidth: 18
  10. implicitHeight: 18
  11. x: control.leftPadding
  12. y: parent.height / 2 - height / 2
  13. radius: 9
  14. //border.color: control.down ? "#17a81a" : "#0099cc"
  15. border.color: control.checked ? "#0099cc" : "#0099cc"
  16. Rectangle {
  17. width: 12
  18. height: 12
  19. x: 3 // (56 - 34) / 2
  20. y: 3
  21. radius: 6
  22. //color: control.down ? "#17a81a" : "#0099cc"
  23. color: control.checked ? "#0099cc" : "#0099cc"
  24. visible: control.checked
  25. }
  26. }
  27. contentItem: Text {
  28. text: control.text
  29. font: control.font
  30. opacity: enabled ? 1.0 : 0.3
  31. //color: control.down ? "#17a81a" : "#21be2b"
  32. verticalAlignment: Text.AlignVCenter
  33. leftPadding: control.indicator.width + control.spacing
  34. }
  35. }