diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index 6cb7c8600d..3268fda2fc 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -58,6 +58,7 @@ #endif #include #include +#include #include #include @@ -588,12 +589,23 @@ QString QAbstractItemDelegatePrivate::textForRole(Qt::ItemDataRole role, const Q case QVariant::DateTime: text = locale.toString(value.toDateTime(), formatType); break; - default: - text = value.toString(); + default: { + if (value.canConvert()) { + const QJsonValue val = value.toJsonValue(); + if (val.isBool()) + text = QVariant(val.toBool()).toString(); + else if (val.isDouble()) + text = locale.toString(val.toDouble(), 'g', precision); + else if (val.isString()) + text = val.toString(); + } else { + text = value.toString(); + } if (role == Qt::DisplayRole) text.replace(QLatin1Char('\n'), QChar::LineSeparator); break; } + } return text; }