Skip to content

Commit 0ccdd6c

Browse files
committed
Fix behaviour of double inputs when pressing enter
1 parent 8131303 commit 0ccdd6c

3 files changed

Lines changed: 7 additions & 5 deletions

File tree

gui/source/pre/views/ArrowMassView.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ ArrowMassView::ArrowMassView(QAbstractItemModel* model, QPersistentModelIndex in
9090

9191
// Keep model up to date on changes
9292
QObject::connect(selectionBox, &QComboBox::currentIndexChanged, this, updateModel);
93-
QObject::connect(massEdit, &DoubleSpinBox::valueChanged, this, updateModel);
94-
QObject::connect(massPerForceEdit, &DoubleSpinBox::valueChanged, this, updateModel);
95-
QObject::connect(massPerEnergyEdit, &DoubleSpinBox::valueChanged, this, updateModel);
93+
QObject::connect(massEdit, &DoubleSpinBox::contentModified, this, updateModel);
94+
QObject::connect(massPerForceEdit, &DoubleSpinBox::contentModified, this, updateModel);
95+
QObject::connect(massPerEnergyEdit, &DoubleSpinBox::contentModified, this, updateModel);
9696
}

gui/source/pre/views/DrawLengthView.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,5 @@ DrawLengthView::DrawLengthView(QAbstractItemModel* model, QPersistentModelIndex
8686

8787
// Keep model up to date on changes
8888
QObject::connect(selectionBox, &QComboBox::currentIndexChanged, this, updateModel);
89-
QObject::connect(lengthEdit, &DoubleSpinBox::valueChanged, this, updateModel);
89+
QObject::connect(lengthEdit, &DoubleSpinBox::contentModified, this, updateModel);
9090
}

gui/source/pre/widgets/DoubleSpinBox.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ DoubleSpinBox::DoubleSpinBox(const Quantity& quantity, const DoubleRange& range,
1919
// Prevent catching focus when scrolling, https://stackoverflow.com/a/19382766
2020
setFocusPolicy(Qt::StrongFocus);
2121

22-
QObject::connect(lineEdit(), &QLineEdit::editingFinished, this, &DoubleSpinBox::contentModified); // Signal modification by user when the text was edited
22+
// Signal modification by user when the text was edited
23+
// QDoubleSpinBox::valueChanged is not used because it is triggered during typing, leading to unnecessary updates of the model.
24+
QObject::connect(this, &QDoubleSpinBox::editingFinished, this, &DoubleSpinBox::contentModified);
2325
QObject::connect(&quantity, &Quantity::unitChanged, this, &DoubleSpinBox::updateUnit);
2426
updateUnit();
2527
}

0 commit comments

Comments
 (0)