X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fprop%2Fdouble.cpp;h=57512d723ff26b5cd3473432040e975cf914e8bb;hp=e1539a127d63dccd9830673a21d66bd07e343f69;hb=dbed5609ae31cdfc3e9db10f3ab91b7607c08372;hpb=7dd518b81be3a446017040dc758003d236e158ff diff --git a/pv/prop/double.cpp b/pv/prop/double.cpp index e1539a1..57512d7 100644 --- a/pv/prop/double.cpp +++ b/pv/prop/double.cpp @@ -58,9 +58,6 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit) if (!variant.gobj()) return nullptr; - double value = Glib::VariantBase::cast_dynamic>( - variant).get(); - spin_box_ = new QDoubleSpinBox(parent); spin_box_->setDecimals(decimals_); spin_box_->setSuffix(suffix_); @@ -69,7 +66,7 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit) if (step_) spin_box_->setSingleStep(*step_); - spin_box_->setValue(value); + update_widget(); if (auto_commit) connect(spin_box_, SIGNAL(valueChanged(double)), @@ -78,6 +75,19 @@ QWidget* Double::get_widget(QWidget *parent, bool auto_commit) return spin_box_; } +void Double::update_widget() +{ + if (!spin_box_) + return; + + Glib::VariantBase variant = getter_(); + assert(variant.gobj()); + + double value = Glib::VariantBase::cast_dynamic>( + variant).get(); + spin_box_->setValue(value); +} + void Double::commit() { assert(setter_);