PIVariantEditors::NumberBase works without attributes

This commit is contained in:
2023-02-07 23:25:12 +03:00
parent 3c29b7b566
commit aec577611b

View File

@@ -195,6 +195,7 @@ void PIVariantEditors::NumberBase::retranslate() {
void PIVariantEditors::NumberBase::applyAttributes(const PIVariantMap & a) {
Type new_type = static_cast<Type>(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<QDoubleSpinBox *>(widget);