diff --git a/src/libs/utils/persistentsettings.cpp b/src/libs/utils/persistentsettings.cpp index c193e754085..ac84a1731af 100644 --- a/src/libs/utils/persistentsettings.cpp +++ b/src/libs/utils/persistentsettings.cpp @@ -357,6 +357,12 @@ FilePath PersistentSettingsReader::filePath() \sa Utils::PersistentSettingsReader */ +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) +static QString xmlAttrFromKey(const Key &key) { return stringFromKey(key); } +#else +static Key xmlAttrFromKey(const Key &key) { return key; } +#endif + static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx, const QVariant &variant, const Key &key = {}) { @@ -367,7 +373,7 @@ static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx, w.writeStartElement(ctx.valueListElement); w.writeAttribute(ctx.typeAttribute, "QVariantList"); if (!key.isEmpty()) - w.writeAttribute(ctx.keyAttribute, key); + w.writeAttribute(ctx.keyAttribute, xmlAttrFromKey(key)); const QList list = variant.toList(); for (const QVariant &var : list) writeVariantValue(w, ctx, var); @@ -376,7 +382,7 @@ static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx, w.writeStartElement(ctx.valueMapElement); w.writeAttribute(ctx.typeAttribute, "QVariantMap"); if (!key.isEmpty()) - w.writeAttribute(ctx.keyAttribute, key); + w.writeAttribute(ctx.keyAttribute, xmlAttrFromKey(key)); const Store varMap = storeFromVariant(variant); const Store::const_iterator cend = varMap.constEnd(); for (Store::const_iterator i = varMap.constBegin(); i != cend; ++i) @@ -390,7 +396,7 @@ static void writeVariantValue(QXmlStreamWriter &w, const Context &ctx, w.writeStartElement(ctx.valueElement); w.writeAttribute(ctx.typeAttribute, QLatin1String(variant.typeName())); if (!key.isEmpty()) - w.writeAttribute(ctx.keyAttribute, key); + w.writeAttribute(ctx.keyAttribute, xmlAttrFromKey(key)); switch (variant.type()) { case QVariant::Rect: w.writeCharacters(rectangleToString(variant.toRect()));