From c924c05ae226524755b1701a5a40e436a08ca2e6 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 21 Mar 2022 09:02:48 +0100 Subject: [PATCH] Replace deprecated QColor::fromString in tests and documentation Don't use deprecated methods in tests, and don't refer to them in documentation. Change-Id: I110480742d9a7b9b0a2e194e3fe610208c1e07da Reviewed-by: Marc Mutz --- src/gui/painting/qcolor.cpp | 4 ++-- src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc | 2 +- tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qcolor.cpp b/src/gui/painting/qcolor.cpp index d576564192..7541059f77 100644 --- a/src/gui/painting/qcolor.cpp +++ b/src/gui/painting/qcolor.cpp @@ -416,7 +416,7 @@ static QStringList get_colornames() A color can be set by passing an RGB string (such as "#112233"), or an ARGB string (such as "#ff112233") or a color name (such as "blue"), - to the setNamedColor() function. + to the fromString() function. The color names are taken from the SVG 1.0 color names. The name() function returns the name of the color in the format "#RRGGBB". Colors can also be set using setRgb(), setHsv() and @@ -871,7 +871,7 @@ QColor::QColor(Spec spec) noexcept Returns the name of the color in the specified \a format. - \sa setNamedColor(), NameFormat + \sa fromString(), NameFormat */ QString QColor::name(NameFormat format) const diff --git a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc index d255b3b98f..e37d5ea51d 100644 --- a/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc +++ b/src/widgets/doc/src/widgets-and-layouts/stylesheet.qdoc @@ -2927,7 +2927,7 @@ | \tt{hsl(\e{h}, \e{s}, \e{l})} \br | \tt{hsla(\e{h}, \e{s}, \e{l}, \e{a})} \br | \tt{#\e{rrggbb}} \br - | \l{QColor::setNamedColor()}{Color Name} \br + | \l{QColor::fromString()}{Color Name} \br \li Specifies a color as RGB (red, green, blue), RGBA (red, green, blue, alpha), HSV (hue, saturation, value), HSVA (hue, saturation, value, alpha), HSL (hue, saturation, diff --git a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp index aea5cb3ac3..093b9c8eaf 100644 --- a/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp +++ b/tests/auto/gui/kernel/qguivariant/test/tst_qguivariant.cpp @@ -245,7 +245,7 @@ void tst_QGuiVariant::toColor_data() QTest::newRow("qstring(#ff0000)") << QVariant(QString::fromUtf8("#ff0000")) << c; QTest::newRow("qbytearray(#ff0000)") << QVariant(QByteArray("#ff0000")) << c; - c.setNamedColor("#88112233"); + c = QColor::fromString("#88112233"); QTest::newRow("qstring(#88112233)") << QVariant(QString::fromUtf8("#88112233")) << c; QTest::newRow("qbytearray(#88112233)") << QVariant(QByteArray("#88112233")) << c; }