diff options
Diffstat (limited to 'src/widgets/itemviews/qabstractitemdelegate.cpp')
-rw-r--r-- | src/widgets/itemviews/qabstractitemdelegate.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/widgets/itemviews/qabstractitemdelegate.cpp b/src/widgets/itemviews/qabstractitemdelegate.cpp index c9f321c3f6..7bc0ece4b3 100644 --- a/src/widgets/itemviews/qabstractitemdelegate.cpp +++ b/src/widgets/itemviews/qabstractitemdelegate.cpp @@ -599,18 +599,21 @@ QString QAbstractItemDelegatePrivate::textForRole(Qt::ItemDataRole role, const Q case QVariant::DateTime: text = locale.toString(value.toDateTime(), formatType); break; - default: { - if (value.canConvert<QJsonValue>()) { - 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(); + case QVariant::Type(QMetaType::QJsonValue): { + const QJsonValue val = value.toJsonValue(); + if (val.isBool()) { + text = QVariant(val.toBool()).toString(); + break; + } + if (val.isDouble()) { + text = locale.toString(val.toDouble(), 'g', precision); + break; } + // val is a string (or null) here + Q_FALLTHROUGH(); + } + default: { + text = value.toString(); if (role == Qt::DisplayRole) text.replace(QLatin1Char('\n'), QChar::LineSeparator); break; |