I keep in QString a number with QDoubleSpinBox, but I didn’t work to put a number with three decimal places in QString (and that’s what is required).

strObrabotka.append(QString("%1%2%3").arg(trUtf8("Расстояние от излучающего гидрофона до антенны (м) & ")).arg(ui->sb_rga->value() ).arg(trUtf8(" \\\\"))); 

tried so

  strObrabotka.append(QString("%1%2.3f%3").arg(trUtf8("Расстояние от излучающего гидрофона до антенны (м) & ")).arg(ui->sb_rga->value(),5).arg(trUtf8(" \\\\"))); 

I get this result: "The distance from the radiating hydrophone to the antenna (m) 5.3f"

tried so

  strObrabotka.append(QString("%1%2%3").arg(trUtf8("Расстояние от излучающего гидрофона до антенны (м) & ")).arg(ui->sb_rga->value(),3).arg(trUtf8(" \\\\"))); 

also did not work, I get the following result: "The distance from the radiating hydrophone to the antenna (m) 5"

    2 answers 2

    Use the QString :: number function. Example:

     double n = 5.300d; qDebug() << QString("Расстояние от излучающего гидрофона до антенны (м): %1").arg(QString::number(n, 'f', 3)); 

    Conclusion:

    "Distance from the radiating hydrophone to the antenna (m): 5.300"

    • one
      the method number is more understandable than the method arg. thanks for the reply - timob256
      strObrabotka.append(QString("%1%2%3").arg(trUtf8("Расстояние от излучающего гидрофона до антенны (м) & ")).arg(ui->sb_rga->value(), 0, 'f', 5).arg(trUtf8(" \\\\"))); 

    Distance from the radiating hydrophone to the antenna (m) 5.00000