View Full Version : Convertion between QLineEdit formated to Double
Hi,
How I can convert a QLineEdit with editmask 999.999.999,99 to a double?
If I use lineedit->text().toDouble() only 0(zeros) are returned.
Thanks for help
mazurekwrc
12th June 2008, 14:49
try this
QString text = ineedit->text();
text.remove( QChar( '.' ) );
text.toDouble();
No, see the results:
Value: 111.222.333,44
If I use your code the result is: 1.11222e+08
I really don't know what I do!
Thanks
mazurekwrc
13th June 2008, 07:33
it's kind of notation, use
qDebug( "%f", your_variable );
and you will see what you want
Thanks for your help.
You help-me to understand the process.
Now I'm using this:
QLocale locale;
locale.setDefault(QLocale::German); // Decimal point is Comma: 000.000,00
locale.setNumberOptions(QLocale::OmitGroupSeparato r);
bool ok;
double d;
d = locale.toDouble( LE_TEST->text(), &ok );
if(ok) {
qDebug( "%f", d );
}
The LE_TEST is using inputMask: 999.999.999,99
Thanks
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.