Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDoubleValidator not working as expected on QLineEdit
Qt 6.12 LTS is out! See what's new in the release blog

QDoubleValidator not working as expected on QLineEdit

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 6.4k Views 1 Watching
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    Hi All,

    I have written the following code on QLineEdit.

    QDoubleValidator *doubleVal = new QDoubleValidator( 0.0, 100.0, 2, this );
    lineEdit->setValidator(doubleVal);

    In above code we have set the range from 0 to 100 so when we enter digit above 100 then lineEdit should not allow to enter the value above maximum range as it is right behaviour with the QIntValidator.

    As what i believe is lineedit should not allow to enter the value more then maximum value. Can you please help ?

    Above code allow to enter the value 999999 which is wrong. Help me.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      999999 is neither clearly wrong nor clearly ok. You still can enter 999999e-5 which leads to a valid value.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        I have tried to apply below API.

        doubleVal->setNotation(QDoubleValidator::StandardNotation);

        Then it should not allow but it allows again 999

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          999 returns the Intermediate state, you still can make that number acceptable by inserting a decimal point somewhere.

          1 Reply Last reply
          0

          • Login

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