Double not recognized

  • Hi,

    I have a strange thing:
    In my country, the decimal separator is 'a comma.

    In a line edit with a QDoubleValidator I enter 1,5
    but if i do
    bool bIsOk = false;
    double dValue = <my lineEdit>->text().toDouble(&bIsOk);

    bIsOk is still false.
    Why ? because QDoubleValidator accepts my string.


  • @Roy44


    have a look at the docu QLocale::toDouble should solve your , seperator problem :)

  • double dValue =<my lineEdit>->locale().toDouble(<my lineEdit>->text());

    on the other hand, QLineEdit + QDoubleValidator = QDoubleSpinBox + QDoubleSpinBox::setButtonSymbols(QAbstractSpinBox::NoButtons)
    and you can use QDoubleSpinBox::value to get the value directly in decimal

Log in to reply

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