Important: Please read the Qt Code of Conduct -

QDoubleValidator not working as expected on QLineEdit

  • Hi All,

    I have written the following code on QLineEdit.

    QDoubleValidator *doubleVal = new QDoubleValidator( 0.0, 100.0, 2, this );

    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.

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

  • I have tried to apply below API.


    Then it should not allow but it allows again 999

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

Log in to reply