diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/corelib/kernel/qabstractitemmodel.cpp | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index 0a84ddb..6d6caf5 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -467,9 +467,17 @@ QAbstractItemModel *QAbstractItemModelPrivate::staticEmptyModel() return qEmptyModel(); } +/*! + \internal + return true if \a value contains a numerical type + + This function is used by our Q{Tree,Widget,Table}WidgetModel classes to sort. + We cannot rely on QVariant::canConvert because this would take strings as double + and then not sort strings correctly +*/ bool QAbstractItemModelPrivate::canConvertToDouble(const QVariant &value) { - switch (value.type()) { + switch (value.userType()) { case QVariant::Bool: case QVariant::Int: case QVariant::UInt: @@ -477,6 +485,12 @@ bool QAbstractItemModelPrivate::canConvertToDouble(const QVariant &value) case QVariant::ULongLong: case QVariant::Double: case QVariant::Char: + case QMetaType::Float: + case QMetaType::Short: + case QMetaType::UShort: + case QMetaType::UChar: + case QMetaType::ULong: + case QMetaType::Long: return true; default: return false; |