From 8c9cdef2a94a328119623ed1e60f0ec8222742a4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 9 May 2020 11:25:30 +0200 Subject: [PATCH] Gui: [skip ci] use a widget's text property instead of casting to a specific subtype This way DlgExpressionInput can be used together with the class InputField --- src/Gui/DlgExpressionInput.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index 40e3faa240..ad6f7cb387 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -62,11 +62,10 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path, if (expression) { ui->expression->setText(Base::Tools::fromStdString(expression->toString())); } - else - { - QAbstractSpinBox *sb = dynamic_cast(parent); - if (sb) { - ui->expression->setText(sb->text()); + else { + QVariant text = parent->property("text"); + if (text.canConvert(QMetaType::QString)) { + ui->expression->setText(text.toString()); } }