如何显示双没有指数格式的Qt?



这是一个随机的双数字:0.123456e+13

我想要像这样不带指数显示"0.123456">

QString s = "0.123456e+13";
double d = s.toDouble();
qDebug() << d;  //0.123456e+13
//I try this solution that I search on the internet but it didn't work
double d2 = QStirng::number(d,'g',6).toDouble();
qDebug() << d2; //0.123456e+13

0.123456 e + 13→0.123456qt

显示

假设您打算将0.123456e+13显示为1234560000000,而不是0.123456,那么您可以使用Qt::fixed(就像您使用std::fixed一样):

qDebug() << Qt::fixed << d;

最新更新