From: Juergen Spitzmueller Date: Sun, 21 Mar 2021 11:38:47 +0000 (+0100) Subject: Fix Qt6 deprecation warning (QString::fromUcs4(uint)) X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=52dff70641788cdd99ca40cf30550861555191c3;p=features.git Fix Qt6 deprecation warning (QString::fromUcs4(uint)) --- diff --git a/src/support/qstring_helpers.cpp b/src/support/qstring_helpers.cpp index d34e455640..103f4a9459 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::fromStdWString(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::fromWCharArray(&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)