[RESOLVED] QDoubleSpinBox not displaying the whole number when converted to a QString
Quick question, I have a QDoubleSpinBox set to 4 decimal places and a max of 1000.000000, the weird thing is that if I enter number 123.4567 and then convert the value into a QString I get "123.457" it basically rounds up the last two digits and displays only 7 digits instead of 8.
Any idea why?
This is what I have:
@// number entered in the doubleSpinBox 123.4567
QString numAsString = QString::number(ui->doubleSpinBox->value()); qDebug()<<"Number:"<< numAsString;// this outputs "123.457" qDebug()<<"Number Length: "<< numAsString.length();// this outputs 7 instead of 8@
You don't set the format when creating your QString so you will get a number formated as "g" and with a precision of 6. QString::number can't know how you configured your QDoubleSpinBox.
If you want the text from the spin box directly, you should rather use cleanText()
Make sense now. Cool, I didn't know about cleanText().
Thanks a lot for your help!