Obsolete Members for QFont

QFont 类的以下成员已被废弃。提供这些成员是为了确保旧源代码能够正常运行。我们强烈建议不要在新代码中使用它们。

公共函数

(deprecated in 6.0) int legacyWeight() const
(deprecated in 6.0) void setLegacyWeight(int legacyWeight)

成员函数文档

[deprecated in 6.0] int QFont::legacyWeight() const

自 6.0 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。

请改用weight()。

返回字体粗细值,该值已转换为 Qt 5 及更早版本中使用的非标准字体粗细尺度。

从 Qt 6 开始,系统改用 OpenType 标准的字重标度,而非非标准标度。这需要对使用旧标度的值进行转换。为方便起见,在将使用旧字重标度的代码移植时,可以使用此函数。

另请参阅 setLegacyWeight()、setWeight()、weight() 以及QFontInfo 。

[deprecated in 6.0] void QFont::setLegacyWeight(int legacyWeight)

自 6.0 版本起,此函数已被废弃。我们强烈建议不要在新代码中使用它。

请改用setWeight()。

使用 Qt 5 及更早版本的旧版字体粗细标尺,将字体粗细设置为legacyWeight 。

从 Qt 6 开始,系统改用 OpenType 标准的字重等级,而非非标准等级。这需要对使用旧等级的值进行转换。为方便起见,在将使用旧字重等级的代码移植时,可以使用此函数。

注意:如果 已设置styleName(),则在字体选择时可能会忽略此值。

另请参阅 legacyWeight()、setWeight()、weight() 和QFontInfo 。

© 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.