Migrate away from deprecated API in Qt 5.14

This commit is contained in:
Chocobo1
2019-12-23 09:58:28 +08:00
parent 18de63f743
commit 2422d81de1
7 changed files with 37 additions and 8 deletions

View File

@@ -48,3 +48,31 @@ constexpr typename std::add_const<T>::type asConst(T &&t) noexcept { return std:
// Prevent const rvalue arguments
template <typename T>
void asConst(const T &&) = delete;
namespace List
{
// Replacement for the deprecated`QSet<T> QSet::fromList(const QList<T> &list)`
template <typename T>
QSet<T> toSet(const QList<T> &list)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return {list.cbegin(), list.cend()};
#else
return QSet<T>::fromList(list);
#endif
}
}
namespace Vector
{
// Replacement for the deprecated `QVector<T> QVector::fromStdVector(const std::vector<T> &vector)`
template <typename T>
QVector<T> fromStdVector(const std::vector<T> &vector)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
return {vector.cbegin(), vector.cend()};
#else
return QVector<T>::fromStdVector(vector);
#endif
}
}