UserButton.qml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import QtQuick 2.9
  2. import QtQuick.Controls 2.4
  3. Button {
  4. id: root_Button
  5. font.pointSize: 16 // 设置字体大小
  6. property color clr_font: "#ffffff"
  7. property color clr_backNormal: "#498ff8"
  8. property color clr_backPress: "#0066FF"
  9. property color clr_boardNormal: "#498ff8"
  10. property color clr_boardPress: "#0066FF"
  11. // 设置按钮文本
  12. contentItem: Text {
  13. id: text2
  14. text: root_Button.text
  15. font: root_Button.font
  16. opacity: enabled ? 1.0 : 0.3
  17. //color: clr_font
  18. horizontalAlignment: Text.AlignHCenter
  19. verticalAlignment: Text.AlignVCenter
  20. elide: Text.ElideRight
  21. }
  22. // 设置按钮背景
  23. background: Rectangle {
  24. implicitWidth: 100
  25. implicitHeight: 60
  26. opacity: enabled ? 1 : 0.3
  27. color: "transparent"
  28. Image {
  29. anchors.fill:parent
  30. fillMode: Image.PreserveAspectFit
  31. source:"img/blue_button.png"
  32. }
  33. }
  34. /*
  35. Rectangle {
  36. implicitWidth: 100
  37. implicitHeight: 40
  38. opacity: enabled ? 1 : 0.3
  39. color: root_Button.down ? clr_backPress : clr_backNormal
  40. border.color: root_Button.down ? clr_boardPress : clr_boardNormal
  41. border.width: 1
  42. radius: 6
  43. }
  44. */
  45. }