From aec577611b0c7cf2f2a75792be302e600f585e51 Mon Sep 17 00:00:00 2001 From: peri4 Date: Tue, 7 Feb 2023 23:25:12 +0300 Subject: [PATCH] PIVariantEditors::NumberBase works without attributes --- libs/piqt_utils/pivariant_edit_widgets.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libs/piqt_utils/pivariant_edit_widgets.cpp b/libs/piqt_utils/pivariant_edit_widgets.cpp index 4188e3c..1aedea1 100644 --- a/libs/piqt_utils/pivariant_edit_widgets.cpp +++ b/libs/piqt_utils/pivariant_edit_widgets.cpp @@ -195,6 +195,7 @@ void PIVariantEditors::NumberBase::retranslate() { void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) { Type new_type = static_cast(a.value(Attribute::widgetType).toEnum().selectedValue()); + if (new_type == tInvalid) new_type = tSpinBox; if (type != new_type) { type = new_type; if (widget) delete widget; @@ -215,10 +216,10 @@ void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) { } prefix = a.value(Attribute::prefix).toString(); suffix = a.value(Attribute::suffix).toString(); - double min = a.value(Attribute::minimum).toDouble(); - double max = a.value(Attribute::maximum).toDouble(); - double step = a.value(Attribute::singleStep).toDouble(); - int dec = is_int ? 0 : a.value(Attribute::decimals).toInt(); + double min = a.value(Attribute::minimum, -65535).toDouble(); + double max = a.value(Attribute::maximum, 65535).toDouble(); + double step = a.value(Attribute::singleStep, 1.).toDouble(); + int dec = is_int ? 0 : a.value(Attribute::decimals, 2).toInt(); switch (type) { case tSpinBox: { auto * w = qobject_cast(widget);