Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Use QStringConverter when building with Qt6

Halla Remptdd0ef012b916
diff --git a/libs/global/kis_dom_utils.h b/libs/global/kis_dom_utils.h
index 3250b626e4..880f3fc092 100644
--- a/libs/global/kis_dom_utils.h
+++ b/libs/global/kis_dom_utils.h
@@ -15,6 +15,10 @@
#include <QDomElement>
#include <QLocale>
#include <QColor>
+#include <QIODevice>
+#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
+#include <QStringConverter>
+#endif
#include <klocalizedstring.h>
@@ -36,7 +40,11 @@ namespace KisDomUtils {
inline QString toString(float value) {
QString str;
QTextStream stream;
+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
stream.setCodec("UTF-8");
+#else
+ stream.setEncoding(QStringConverter::Utf8);
+#endif
stream.setString(&str, QIODevice::WriteOnly);
stream.setRealNumberPrecision(FLT_DIG);
stream << value;
@@ -46,7 +54,11 @@ namespace KisDomUtils {
inline QString toString(double value) {
QString str;
QTextStream stream;
+#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
stream.setCodec("UTF-8");
+#else
+ stream.setEncoding(QStringConverter::Utf8);
+#endif
stream.setString(&str, QIODevice::WriteOnly);
stream.setRealNumberPrecision(15);
stream << value;