UserRadioButton.qml 981 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. Rectangle {
  16. width: 12
  17. height: 12
  18. x: 3 // (56 - 34) / 2
  19. y: 3
  20. radius: 6
  21. color: control.down ? "#17a81a" : "#0099cc"
  22. visible: control.checked
  23. }
  24. }
  25. contentItem: Text {
  26. text: control.text
  27. font: control.font
  28. opacity: enabled ? 1.0 : 0.3
  29. //color: control.down ? "#17a81a" : "#21be2b"
  30. verticalAlignment: Text.AlignVCenter
  31. leftPadding: control.indicator.width + control.spacing
  32. }
  33. }