Guest User

Untitled

a guest
Nov 23rd, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. TextField {
  2. id:textField
  3. text:"11:11:11"
  4. width:200
  5. height:80
  6. font.pointSize: 15
  7. color:"white"
  8. inputMask: "99:99:99"
  9. validator: RegExpValidator { regExp: /^([0-1s]?[0-9s]|2[0-3s]):([0-5s][0-9s]):([0-5s][0-9s])$ / }
  10. horizontalAlignment: Text.AlignHCenter
  11. verticalAlignment: Text.AlignVCenter
  12. inputMethodHints: Qt.ImhDigitsOnly
  13. }
  14.  
  15. TextField {
  16. ..
  17. Keys.onBackPressed: text = "00:00:00"
  18. }
  19.  
  20. TextField {
  21. ..
  22. Keys.onBackPressed: {
  23. var index = cursorPosition
  24. var char = text.charAt(index)
  25. if(char != ":"){
  26. text = text.substr(0, index) + "0"+ text.substr(index);
  27. }
  28.  
  29. }
  30. }
Add Comment
Please, Sign In to add comment