diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-09-18 15:45:36 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-10-01 12:15:22 +0200 |
commit | 4d943225eb7b8de22e33771b9389c919d59a4bd3 (patch) | |
tree | 4e6c1de71408d13f54bad71162c5338c0ccfb0a0 /src/corelib/kernel/qvariant.h | |
parent | f518f01be602a2dad00d81457ce480c4db50aa0f (diff) |
Add a QVariant::compare() method
Add a method that allows comparing two variants. The method returns
a std::optional, as comparing two variants of different type is not
meaningful, or the types could not be comparable.
Change-Id: If4ae838d671e051dda1b474f25a2f9dcf85dc265
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/kernel/qvariant.h')
-rw-r--r-- | src/corelib/kernel/qvariant.h | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 83cb40a7c7..c28f841356 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -492,6 +492,8 @@ class Q_CORE_EXPORT QVariant inline bool operator!=(const QVariant &v) const { return !equals(v); } + static std::optional<int> compare(const QVariant &lhs, const QVariant &rhs); + protected: friend inline bool operator==(const QVariant &, const QVariantComparisonHelper &); #ifndef QT_NO_DEBUG_STREAM |