How to convert float64 to QString
-
@VRonin
I want to dsiplay it in QTextedit, dont want to set the value tof textedit to QString
for example
float64 value = 2.33QTextEdit *textbox = new QTextEdit;
textbox->setText(value)QString floatToString = QLocale::system().toString(floatValue,'f'); textbox->setText(floatToString); -
@VRonin I am getting the following error
error: no matching function for call to 'QLocale::toString(float64 [1], char)'
QString floatToString = QLocale::system().toString(data1,'f');@rockon209 Why do you use float64 instead of float or double?
If you want to use float 64 then cast it to float or double first.
And toString isn't a static method - you need a QLocale instance to use it. -
If you mean float64 is equal to double, I would use the static function QString::number.
double value = 1.234567: QString num = QString::number(value); -
@jsulm @beecksche
I am getting the value from a function and that function gives float64 value as return. I thought about that but dont know how to cast float64 to float. If you know it please let me know.double temp = static_cast<double>(value);use double to make sure it can represent all values a float64 can.
-
@VRonin
I want to dsiplay it in QTextedit, dont want to set the value tof textedit to QString
for example
float64 value = 2.33QTextEdit *textbox = new QTextEdit;
textbox->setText(value)@rockon209 said in How to convert float64 to QString:
@VRonin
I want to dsiplay it in QTextedit, dont want to set the value tof textedit to QStringThat's not what I'm doing there
you can even combine.
textEdit->setText(textEdit->locale().toString(floatValue,'f'));