NumberPad.qml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // NumberPad.qml
  2. import QtQuick
  3. import QtQuick.Controls
  4. import QtQuick.Layouts
  5. import Felgo 4.0
  6. Item {
  7. id: numberPadRoot
  8. property alias txtPassword: passwd_tf
  9. property alias mlogin: btn_login
  10. signal buttonClicked()
  11. width: parent.width*0.3
  12. height: parent.height*0.7
  13. Column {
  14. anchors.centerIn: parent
  15. TextField {
  16. id: passwd_tf
  17. anchors.horizontalCenter: parent.horizontalCenter //垂直居中显示
  18. width: parent.width * 0.95
  19. background: Rectangle {
  20. color: "#e9e9e9"
  21. radius: 5
  22. }
  23. font.pixelSize: 30
  24. echoMode: TextInput.Password
  25. //readOnly: false
  26. horizontalAlignment: Qt.AlignLeft
  27. placeholderText: "请输入密码"
  28. cursorDelegate: Rectangle {
  29. visible: false
  30. }
  31. MouseArea {
  32. anchors.fill: parent
  33. onClicked: {
  34. console.log("TextField clicked!")
  35. numberPadRoot.buttonClicked()
  36. }
  37. }
  38. }
  39. Grid {
  40. id: grid
  41. columns: 3
  42. // columnSpacing: -10
  43. // rowSpacing: -5
  44. //spacing: 5
  45. Repeater {
  46. model: 10
  47. AppButton {
  48. flat: false
  49. minimumHeight: 50
  50. minimumWidth: 110
  51. text: (index + 1) % 10
  52. fontBold: true
  53. borderColor: app.cardColor
  54. backgroundColor: app.cardColor
  55. textColor: app.fontColor
  56. onClicked: {
  57. console.log("text:",text)
  58. passwd_tf.text += text
  59. numberPadRoot.buttonClicked()
  60. }
  61. }
  62. }
  63. AppButton {
  64. minimumHeight: 50
  65. minimumWidth: 110
  66. text: "清空"
  67. textColor: app.fontColor
  68. flat: false
  69. backgroundColor: app.cardColor
  70. borderColor: app.cardColor
  71. onClicked: {
  72. passwd_tf.text = ""
  73. numberPadRoot.buttonClicked()
  74. }
  75. }
  76. AppButton {
  77. id: btn_login
  78. minimumHeight: 50
  79. minimumWidth: 110
  80. flat: false
  81. text: "解锁"
  82. textColor: "white"
  83. backgroundColor: "green"
  84. borderColor: "green"
  85. onClicked: {
  86. console.log("解锁")
  87. numberPadRoot.buttonClicked()
  88. }
  89. }
  90. }
  91. }
  92. }