0

I'm getting double value quickly from user with QInputDialog. Actually, everything is fine just wondering if there is a way to write suffix next to this value.

My code:

    double value = QInputDialog::getDouble(this,
                                           tr("Change World Box Size"),
                                           tr("Set each axis length:"),
                                           projectJson.value("worldBox").toObject()["length"].toString().toDouble(),
                                           0,
                                           10000,
                                           2, 
                                           &isOK,
                                           Qt::Dialog,
                                           0.1);

enter image description here

Hakan Kaya
  • 46
  • 4

1 Answers1

0

That seems to work;

    auto dialog = new QInputDialog(this);
    dialog->setWindowTitle("Change World Box Size");
    dialog->setLabelText("Set each axis length:");
    dialog->setDoubleDecimals(2);
    dialog->setDoubleMaximum(10000);
    dialog->setDoubleMinimum(0);
    dialog->setDoubleValue(projectJson.value("worldBox").toObject()["length"].toString().toDouble());

    auto doubleEdit = dialog->findChild<QDoubleSpinBox *>();
    doubleEdit->setSingleStep(0.1);
    doubleEdit->setSuffix(" mm");
    
    if (dialog->exec() == QDialog::Accepted) {
        m_worldBoxGenerator->generate(dialog->doubleValue());
    }

enter image description here

Hakan Kaya
  • 46
  • 4