From 386b608504225213df22a44f72657886943aa2aa Mon Sep 17 00:00:00 2001 From: GriffinR Date: Mon, 9 Mar 2026 16:12:00 -0400 Subject: [PATCH] Disable new conversion error for Qt5 --- include/core/converter.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/core/converter.h b/include/core/converter.h index 3833e0d6..1ac4bd1a 100644 --- a/include/core/converter.h +++ b/include/core/converter.h @@ -70,13 +70,17 @@ struct DefaultConverter { if (!v.canConvert()) { if (errors) errors->append(QString("Can't convert from JSON to type '%1'").arg(v.typeName())); } else { +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) // 'canConvert' is only true if a conversion between types is theoretically possible, // not necessarily if this value can be converted. e.g. "2" can be converted to int (2), // but "hello world" cannot be converted to int and becomes 0. + // For older versions of Qt, we rely on QVariant::value. + T value; bool ok = QMetaType::convert(v.metaType(), v.constData(), QMetaType::fromType(), &value); if (ok) return value; else if (errors) errors->append(QString("Failed to convert JSON value to type '%1'").arg(v.typeName())); +#endif } // For failed conversion, return a default constructed value. return v.value();