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. Validator not working
Qt 6.11 is out! See what's new in the release blog

Validator not working

Scheduled Pinned Locked Moved Solved QML and Qt Quick
2 Posts 2 Posters 2.2k Views
  • 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 Offline
    G Offline
    GoldRatio
    wrote on last edited by
    #1

    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
    0
    • KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by
      #2

      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
      3

      • Login

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