MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / focusOutEvent

Method focusOutEvent

src/Gui/InputField.cpp:684–701  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

682}
683
684void InputField::focusOutEvent(QFocusEvent* event)
685{
686 try {
687 if (Quantity::parse(this->text().toStdString()).isDimensionless()) {
688 // if user didn't enter a unit, we virtually compensate
689 // the multiplication factor induced by user unit system
690 double factor;
691 std::string unitStr;
692 actQuantity.getUserString(factor, unitStr);
693 actQuantity = actQuantity * factor;
694 }
695 }
696 catch (const Base::ParserError&) {
697 // do nothing, let apply the last known good value
698 }
699 this->setText(QString::fromStdString(actQuantity.getUserString()));
700 QLineEdit::focusOutEvent(event);
701}
702
703void InputField::keyPressEvent(QKeyEvent* event)
704{

Callers

nothing calls this directly

Calls 6

isDimensionlessMethod · 0.80
toStdStringMethod · 0.80
parseFunction · 0.50
textMethod · 0.45
getUserStringMethod · 0.45
setTextMethod · 0.45

Tested by

no test coverage detected