Skip to content

Commit db36c65

Browse files
dfaure-kdabdantti
authored andcommitted
Port away from deprecated API in Qt 6.6: QColor::setNamedColor
The replacement, QColor::fromString() exists since Qt 6.4.
1 parent 12ff98d commit db36c65

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

QXlsx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ target_compile_definitions(QXlsx PRIVATE
147147
QT_USE_QSTRINGBUILDER
148148
QT_NO_SIGNALS_SLOTS_KEYWORDS
149149
QT_USE_FAST_OPERATOR_PLUS
150-
QT_DISABLE_DEPRECATED_BEFORE=0x060200
150+
QT_DISABLE_DEPRECATED_BEFORE=0x060600
151151
)
152152

153153
if (NOT WIN32)

QXlsx/source/xlsxcolor.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,21 @@ XlsxColor::operator QVariant() const
116116

117117
QColor XlsxColor::fromARGBString(const QString &c)
118118
{
119+
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
120+
if (c.startsWith(u'#')) {
121+
return QColor::fromString(c);
122+
} else {
123+
return QColor::fromString(QLatin1Char('#') + c);
124+
}
125+
#else
119126
QColor color;
120127
if (c.startsWith(u'#')) {
121128
color.setNamedColor(c);
122129
} else {
123130
color.setNamedColor(QLatin1Char('#') + c);
124131
}
125132
return color;
133+
#endif
126134
}
127135

128136
QString XlsxColor::toARGBString(const QColor &c)

0 commit comments

Comments
 (0)