Solved QOBject::tr() with floating-point number
-
I would like to get the
QMessageBox
showing the double precision value of the variablemy_double
. But I got it showing the value0
.double my_double = 0.1234567; QMessageBox::warning( nullptr, QObject::tr("Warning"), QObject::tr("The value %n is a double precision number", "", my_double), QMessageBox::Ok);
How can I do it?
-
QObject::tr("The value %1 is a double precision number").arg( my_double),
-
Hi,
Are you looking for QLocale::toString ?
-
@fem_dev I guess
%n
is for natural, countable things. What would you expect as singular/plural for a double?Regards
-
QObject::tr("The value %1 is a double precision number").arg( my_double),
-
@mpergand said in QOBject::tr() with floating-point number:
QObject::tr("The value %1 is a double precision number").arg( my_double),
Thank you @mpergand ! This solution works great!