Qt Forum

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

    Solved Validator not working

    QML and Qt Quick
    2
    2
    1276
    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.
    • G
      GoldRatio last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • KillerSmath
        KillerSmath last edited by

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

        @Computer Science Student - Brazil
        Web Developer and Researcher
        “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

        1 Reply Last reply Reply Quote 3
        • First post
          Last post