1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-01-30 05:02:52 +08:00

Port away from deprecated API in Qt 6.6: QColor::setNamedColor

The replacement, QColor::fromString() exists since Qt 6.4.
This commit is contained in:
David Faure 2024-07-03 15:45:37 +02:00 committed by Daniel Nicoletti
parent 12ff98db76
commit db36c652ed
2 changed files with 9 additions and 1 deletions

View File

@ -147,7 +147,7 @@ target_compile_definitions(QXlsx PRIVATE
QT_USE_QSTRINGBUILDER QT_USE_QSTRINGBUILDER
QT_NO_SIGNALS_SLOTS_KEYWORDS QT_NO_SIGNALS_SLOTS_KEYWORDS
QT_USE_FAST_OPERATOR_PLUS QT_USE_FAST_OPERATOR_PLUS
QT_DISABLE_DEPRECATED_BEFORE=0x060200 QT_DISABLE_DEPRECATED_BEFORE=0x060600
) )
if (NOT WIN32) if (NOT WIN32)

View File

@ -116,6 +116,13 @@ XlsxColor::operator QVariant() const
QColor XlsxColor::fromARGBString(const QString &c) 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; QColor color;
if (c.startsWith(u'#')) { if (c.startsWith(u'#')) {
color.setNamedColor(c); color.setNamedColor(c);
@ -123,6 +130,7 @@ QColor XlsxColor::fromARGBString(const QString &c)
color.setNamedColor(QLatin1Char('#') + c); color.setNamedColor(QLatin1Char('#') + c);
} }
return color; return color;
#endif
} }
QString XlsxColor::toARGBString(const QColor &c) QString XlsxColor::toARGBString(const QColor &c)