- Qt 6.4
- Qt GUI
- C++ Classes
- QColor
- Qt 6.4.3 Reference Documentation

# Obsolete Members for QColor

The following members of class QColor are deprecated. They are provided to keep old source code working. We strongly advise against using them in new code.

## Public Functions

`(deprecated (6.6))` void | setNamedColor(const QString &name)
`(deprecated (6.6))` void | setNamedColor(QStringView name)
`(deprecated (6.6))` void | setNamedColor(QLatin1StringView name)

## Static Public Members

`(deprecated (6.6))` bool | isValidColor(const QString &name)
`(deprecated (6.6))` bool | isValidColor(QStringView name)
`(deprecated (6.6))` bool | isValidColor(QLatin1StringView name)

## Member Function Documentation

### `[static]` bool QColor::isValidColor(const QString &name)

This function is deprecated since 6.6. We strongly advise against using it in new code.

Use isValidColorName() instead.

Returns `true` if the name is a valid color name and can be used to construct a valid QColor object, otherwise returns false.

It uses the same algorithm used in setNamedColor().

See also setNamedColor().

### `[static, since 5.10]` bool QColor::isValidColor(QStringView name)

This function is deprecated since 6.6. We strongly advise against using it in new code.

This is an overloaded function.

Use isValidColorName() instead.

This function was introduced in Qt 5.10.

### `[static, since 5.8]` bool QColor::isValidColor(QLatin1StringView name)

This function is deprecated since 6.6. We strongly advise against using it in new code.

This is an overloaded function.

Use isValidColorName() instead.

This function was introduced in Qt 5.8.

### void QColor::setNamedColor(const QString &name)

This function is deprecated since 6.6. We strongly advise against using it in new code.

Use fromString() instead.

Sets the RGB value of this QColor to name, which may be in one of these formats:

- #RGB (each of R, G, and B is a single hex digit)
- #RRGGBB
- #AARRGGBB (Since 5.2)
- #RRRGGGBBB
- #RRRRGGGGBBBB
- A name from the list of colors defined in the list of SVG color keyword names provided by the World Wide Web Consortium; for example, "steelblue" or "gainsboro". These color names work on all platforms. Note that these color names are not the same as defined by the Qt::GlobalColor enums, e.g. "green" and Qt::green does not refer to the same color.
- `transparent` - representing the absence of a color.

The color is invalid if name cannot be parsed.

See also QColor(), name(), and isValid().

### `[since 5.10]` void QColor::setNamedColor(QStringView name)

This function is deprecated since 6.6. We strongly advise against using it in new code.

This is an overloaded function.

Use fromString() instead.

This function was introduced in Qt 5.10.

### `[since 5.8]` void QColor::setNamedColor(QLatin1StringView name)

This function is deprecated since 6.6. We strongly advise against using it in new code.

This is an overloaded function.

Use fromString() instead.

This function was introduced in Qt 5.8.