]> git.lyx.org Git - features.git/commitdiff
Fix Qt6 deprecation warning (QString::fromUcs4(uint))
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 21 Mar 2021 11:38:47 +0000 (12:38 +0100)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 21 Mar 2021 11:38:47 +0000 (12:38 +0100)
src/support/qstring_helpers.cpp

index d34e455640d012c13d660c6e67f0bd4374b384d3..103f4a9459e4e4aa7d9c92e62557b6796917785e 100644 (file)
@@ -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)