Obsolete Members for QColor
QColor 类的以下成员已被废弃。提供这些成员是为了确保旧源代码能够继续运行。我们强烈建议不要在新代码中使用它们。
公共函数
(deprecated in 6.6) void | setNamedColor(const QString &name) |
(deprecated in 6.6) void | setNamedColor(QLatin1StringView name) |
(deprecated in 6.6) void | setNamedColor(QStringView name) |
静态公共成员
(deprecated in 6.6) bool | isValidColor(const QString &name) |
(deprecated in 6.6) bool | isValidColor(QLatin1StringView name) |
(deprecated in 6.6) bool | isValidColor(QStringView name) |
成员函数文档
[static, deprecated in 6.6] bool QColor::isValidColor(const QString &name)
自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。
请改用 `isValidColorName()`。
如果 `name ` 是一个有效的颜色名称,并且可以用于构建一个有效的 `QColor ` 对象,则返回 `true `;否则返回 `false`。
它使用与fromString() 相同的算法。
另请参阅 fromString()。
[static noexcept, deprecated in 6.6] bool QColor::isValidColor(QLatin1StringView name)
自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。
请改用 `isValidColorName()`。
这是一个重载函数。
[static noexcept, deprecated in 6.6] bool QColor::isValidColor(QStringView name)
自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。
请改用 `isValidColorName()`。
这是一个重载函数。
[deprecated in 6.6] void QColor::setNamedColor(const QString &name)
自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。
请改用fromString()。
将此QColor 的RGB值设置为name ,其格式可为以下之一:
- #RGB(R、G 和 B 各为一位十六进制数字)
- #RRGGBB
- #AARRGGBB(自 5.2 起)
- #RRRGGGBBB
- #RRRRGGGGBBBB
- 来自万维网联盟(W3C)提供的SVG 颜色关键字名称列表中定义的颜色名称;例如,“steelblue”或“gainsboro”。这些颜色名称在所有平台上均有效。 请注意,这些颜色名称与Qt::GlobalColor 枚举中定义的名称并不相同,例如“green”和Qt::green 所指的颜色并不相同。
transparent- 表示无颜色。
如果无法解析name ,则该颜色无效。
另请参阅 QColor()、name() 和isValid()。
[deprecated in 6.6] void QColor::setNamedColor(QLatin1StringView name)
自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。
请改用 `fromString()`。
这是一个重载函数。
[deprecated in 6.6] void QColor::setNamedColor(QStringView name)
自 6.6 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。
请改用 `fromString()`。
这是一个重载函数。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.