Validator not working



  • I'm developing something for mobile, and I need to set a double validator, however, it doesn't work as I am able to enter in values greater than the top and bottom values that I have set. The text field I am using is connected to a C++ backend that records the values input into the TextField.

    TextField{
        id: textField
        text:  Data.number
        width: 75
        inputMethodHints: Qt.ImhFormattedNumbersOnly
        validator: DoubleValidator{ bottom: 0.0; top: 10.0;}
        focus: true
        onTextChanged: Data.number = text
    }
    

    Can anyone tell me what is wrong with the code? By the way if I change the validator to an IntValidator it works as supposed to allowing me only to enter digits from 0 to 10, however, I need the number to be a double in order to type in decimal numbers. Is there any other way to accomplish getting a textField to only take in a certain range of numbers that can have decimals in them?

    Thanks in advance!



  • A good explanation and solution for your problem:
    https://stackoverflow.com/a/35223994


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.