Skip to content

Commit

Permalink
Port away from deprecated API in Qt 6.6: QColor::setNamedColor
Browse files Browse the repository at this point in the history
The replacement, QColor::fromString() exists since Qt 6.4.
  • Loading branch information
dfaure-kdab committed Jul 4, 2024
1 parent 12ff98d commit 016a91c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion QXlsx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ target_compile_definitions(QXlsx PRIVATE
QT_USE_QSTRINGBUILDER
QT_NO_SIGNALS_SLOTS_KEYWORDS
QT_USE_FAST_OPERATOR_PLUS
QT_DISABLE_DEPRECATED_BEFORE=0x060200
QT_DISABLE_DEPRECATED_BEFORE=0x060600
)

if (NOT WIN32)
Expand Down
8 changes: 8 additions & 0 deletions QXlsx/source/xlsxcolor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,21 @@ XlsxColor::operator QVariant() const

QColor XlsxColor::fromARGBString(const QString &c)
{
#if QT_VERSION >= QT_VERSION_CHECK(6, 4, 0)
if (c.startsWith(u'#')) {
return QColor::fromString(c);
} else {
return QColor::fromString(QLatin1Char('#') + c);
}
#else
QColor color;
if (c.startsWith(u'#')) {
color.setNamedColor(c);
} else {
color.setNamedColor(QLatin1Char('#') + c);
}
return color;
#endif
}

QString XlsxColor::toARGBString(const QColor &c)
Expand Down

0 comments on commit 016a91c

Please sign in to comment.