17 #include <QDoubleValidator>
19 #include <QVBoxLayout>
23 const int max_digits = 1000;
32 setAutoFillBackground(
true);
34 auto layout =
new QVBoxLayout;
36 layout->setSpacing(0);
40 m_validator =
new QDoubleValidator(0.0, std::numeric_limits<double>::max(), max_digits,
this);
41 m_validator->setNotation(QDoubleValidator::ScientificNotation);
44 connect(
m_lineEdit, &QLineEdit::editingFinished,
this,
52 m_validator->setRange(minimum, maximum, max_digits);
57 double new_value =
m_lineEdit->text().toDouble();
65 if (
m_data.type() != QVariant::Double)
66 throw std::runtime_error(
67 "ScientificDoubleEditor::update_components() -> Error. Wrong variant type");
Base class for all custom variant editors.
void setDataIntern(const QVariant &data)
Saves the data as given by editor's internal components and notifies the model.
void update_components() override
Should update widget components from m_data, if necessary.
void setRange(double minimum, double maximum)
ScientificDoubleEditor(QWidget *parent=nullptr)
QDoubleValidator * m_validator
MVVM_MODEL_EXPORT bool AreAlmostEqual(double a, double b, double tolerance_factor=1.0)
Returns true if two doubles agree within epsilon*tolerance.
materialitems.h Collection of materials to populate MaterialModel.