Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. RegExpValidator, empty field
Qt 6.11 is out! See what's new in the release blog

RegExpValidator, empty field

Scheduled Pinned Locked Moved Solved QML and Qt Quick
6 Posts 2 Posters 824 Views 1 Watching
  • 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.
  • qtprogrammer123Q Offline
    qtprogrammer123Q Offline
    qtprogrammer123
    wrote on last edited by
    #1

    Hi i have regex for validate IP adress. but also wonna accept empty field - i need it for action in onEditingFinished.

    validator: RegExpValidator {
      regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/
    }
    

    Mam moc jak Harry Potter, w zębach mogę przenieść hotel.

    raven-worxR 1 Reply Last reply
    0
    • qtprogrammer123Q Offline
      qtprogrammer123Q Offline
      qtprogrammer123
      wrote on last edited by
      #6
      regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])**|()**$/
      

      Mam moc jak Harry Potter, w zębach mogę przenieść hotel.

      1 Reply Last reply
      0
      • qtprogrammer123Q qtprogrammer123

        Hi i have regex for validate IP adress. but also wonna accept empty field - i need it for action in onEditingFinished.

        validator: RegExpValidator {
          regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/
        }
        
        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #2

        @qtprogrammer123 said in RegExpValidator, empty field:

        ut also wonna accept empty field

        what is an empty field for you? "255.255", "255...", "255.255.-.-", etc.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        0
        • qtprogrammer123Q Offline
          qtprogrammer123Q Offline
          qtprogrammer123
          wrote on last edited by
          #3

          Empty TextField - ""

          Mam moc jak Harry Potter, w zębach mogę przenieść hotel.

          raven-worxR 1 Reply Last reply
          0
          • qtprogrammer123Q qtprogrammer123

            Empty TextField - ""

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #4

            @qtprogrammer123

            /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])?.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])?$/

            but this would also accept "255...255" for example (empty groups inbetween)

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            0
            • qtprogrammer123Q Offline
              qtprogrammer123Q Offline
              qtprogrammer123
              wrote on last edited by
              #5
              TextField {
                  id: ipField
              
                  width: 180; height: parent.height
                  Font{
                      bold: true
                      pixelSize: 15
                  }
              
              
                  text: settings.ip
                  placeholderText: qsTr("255.255.255.255")
                  validator: RegExpValidator {
                      regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])$/
                  }
              
                  onEditingFinished: {
                      if(text == "") console.log("It will never print ")
                      else  console.log(text);
                  }
              }
              

              I need do action in onEditingFinished handler when field is empty - i can't do that becouse regex accept only ip, so editingFinished() never be emitted

              Mam moc jak Harry Potter, w zębach mogę przenieść hotel.

              1 Reply Last reply
              0
              • qtprogrammer123Q Offline
                qtprogrammer123Q Offline
                qtprogrammer123
                wrote on last edited by
                #6
                regExp: /^((?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])\.){0,3}(?:[0-1]?[0-9]?[0-9]|2[0-4][0-9]|25[0-5])**|()**$/
                

                Mam moc jak Harry Potter, w zębach mogę przenieść hotel.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved