Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved TextField Validation in QML

    QML and Qt Quick
    textfield qtquick2 qtquickcontrols
    1
    1
    948
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      pra7 last edited by

      I am having a TextField which allows the user to enter time and I have used RegValidator to validate. Currently, i need to fill with "0" when user clicks on backspace. Following is the code:

      TextField {
          id:textField
          text:"11:11:11"
          width:200
          height:80
          font.pointSize: 15
          color:"white"
          inputMask: "99:99:99"
          validator: RegExpValidator { regExp: /^([0-1\s]?[0-9\s]|2[0-3\s]):([0-5\s][0-9\s]):([0-5\s][0-9\s])$ / }
          horizontalAlignment: Text.AlignHCenter
          verticalAlignment: Text.AlignVCenter
          inputMethodHints: Qt.ImhDigitsOnly
      }
      
      1 Reply Last reply Reply Quote 0
      • First post
        Last post