Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-86730

TextInput.acceptableInput remains false

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 5.12.7, 5.15.1
    • Fix Version/s: None
    • Labels:
      None
    • Platform/s:
      Android

      Description

      In the following example, I have a TextInput where the font color should become green whenever a valid IP address is entered.  This works fine on Linux and on some Android phones.  However, it fails on eg a Mi Mix 3 and Google Pixel 3

      When adding logging, it seems that `txtInput.text` becomes empty right after entering the digit that makes the entry valid (txtInput.displayText remains correct).  

      Using `rect.ipRegex.test(displayText)` instead of `acceptableInput` works just fine hence it has a low priority.

      Not sure whether other validators will show the same erroneous behavior.

       

      import QtQuick 2.12
      import QtQuick.Window 2.12
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Rectangle {
              id: rect
              width: 100
              height: 40
              color: "grey"
      
              property var ipRegex: /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
      
              TextInput {
                  id: txtInput
                  anchors.fill: parent
                  text: ""
                  color: acceptableInput? "green" : "red"
                  inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase
                  validator: RegExpValidator {
                      id: validatorId
                      regExp:  rect.ipRegex
                  }
               }
          }
      } 

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qt.team.quick.subscriptions Qt Quick and Widgets Team
            Reporter:
            vdaele vdaele
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes