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

RegExpValidator is not applied to a TextInput component in creation

    XMLWordPrintable

Details

    Description

      In QML a RegExpValidator is not applied right after TextInput component is created. As QRegExpValidator will accept anything by default, TextInput.acceptableInput will return true when the component is created. Once TextInput value is modified, the right regexp is applied.

      The following code will show the issue. When the application is started the acceptableInput will be true thus the color is set to green.

      import QtQuick 1.0
      Rectangle {
          id: root
          color: input.acceptableInput ? "green" : "red"
          width: 300; height: 300
          Rectangle {
              anchors.centerIn: parent
              height: 50
              width: 50
              color: "white"
              TextInput {
                  id: input
                  anchors.fill: parent
                  validator: RegExpValidator { regExp: /.{1,4}/ } 
              }
          }
      }
      

      Attachments

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

        Activity

          People

            denexter Andrew den Exter (closed Nokia identity) (Inactive)
            qtcomsupport Qt Support
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes