From 6fa973b3771ff9ff61d82ae3cbebad8442d30816 Mon Sep 17 00:00:00 2001 From: Enrico Forestieri Date: Sun, 21 Mar 2021 17:15:08 +0100 Subject: [PATCH] Fix Qt6 deprecation warning about QString::fromUcs4 --- src/support/qstring_helpers.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/support/qstring_helpers.cpp b/src/support/qstring_helpers.cpp index d34e455640..19cac062fb 100644 --- a/src/support/qstring_helpers.cpp +++ b/src/support/qstring_helpers.cpp @@ -47,13 +47,21 @@ QString toqstr(docstring const & ucs4) // need to be superfast. if (ucs4.empty()) return QString(); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + return QString::fromStdU32String(reinterpret_cast(ucs4)); +#else return QString::fromUcs4((uint const *)ucs4.data(), ucs4.length()); +#endif } QString toqstr(char_type ucs4) { +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)) + return QString::fromStdU32String(std::u32string(ucs4, 1)); +#else union { char_type c; uint i; } u = { ucs4 }; return QString::fromUcs4(&u.i, 1); +#endif } docstring qstring_to_ucs4(QString const & qstr)