Commit 16dc0de8 authored by SZPYRKA Jean-Luc's avatar SZPYRKA Jean-Luc

check bounds

parent 766376a0
......@@ -43,9 +43,10 @@ int main(int argc, char **argv)
qInfo() << "real_parameter (dbl)=" << value;
});
dtk::d_real scientific_parameter = 8.654321;
scientific_parameter.setDocumentation("A real parameter.");
scientific_parameter.setDecimals(6);
dtk::d_real scientific_parameter("A scientific parameter", 8.54321, -1.0e+6, +1.0e+6, 6); // doc, value, min, max, decimals
//scientific_parameter = 8.654321;
//scientific_parameter->setDecimals(6);
dtkWidgetsParameter *scientific_parameter_widget = dtk::widgets::parameters::pluginFactory().create(&scientific_parameter, "dtkWidgetsParameterScientificSpinBox");
scientific_parameter.connect([=] (QVariant v) {
......
......@@ -56,6 +56,13 @@ void dtkDoubleSpinBoxPrivate::touch()
QString dtkDoubleSpinBoxPrivate::textFromValue ( double value ) const
{
QString strValue;
if (value < this->minimum)
value = this->minimum;
if (value > this->maximum)
value = this->maximum;
if (this->scientific)
strValue = QString::number(value, 'e', this->decimals);
else
......@@ -96,6 +103,13 @@ double dtkDoubleSpinBoxPrivate::valueFromText ( const QString & text ) const
}
double dblValue = result.toDouble();
// check min/max ? What if decimals or min and max are inadequate ?
if (dblValue < this->minimum)
dblValue = this->minimum;
if (dblValue > this->maximum)
dblValue = this->maximum;
//q->lineEdit()->blockSignals(true); // protected !!
//q->lineEdit()->setText(result);
//q->lineEdit()->blockSignals(false);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment