QFont::Tag Struct
struct QFont::TagQFont::Tag 类型可提供高级字体功能。更多
此结构在 Qt 6.7 中引入。
公共函数
Tag() | |
Tag(const char (&)[N] str) | |
bool | isValid() const |
QByteArray | toString() const |
quint32 | value() const |
静态公共成员
std::optional<QFont::Tag> | fromString(QAnyStringView view) |
std::optional<QFont::Tag> | fromValue(quint32 value) |
相关非成员
Qt::strong_ordering | compareThreeWay(const QFont::Tag &lhs, const QFont::Tag &rhs) |
bool | comparesEqual(const QFont::Tag &lhs, const QFont::Tag &rhs) |
size_t | qHash(QFont::Tag key, size_t seed = 0) |
详细说明
QFont 为文本整形提供了高级功能。特征由标签定义,标签可以是四字符串,也可以是 32 位整数值。该类型以类型安全的方式表示这种标记。它可以由 4 个字符、8 位字符串字面量或相应的 32 位整数值构成。使用更短或更长的字符串字面将导致编译时错误。
QFont font; // Correct font.setFeature("frac"); // Wrong - won't compile font.setFeature("fraction"); // Wrong - will produce runtime warning and fail font.setFeature(u"fraction"_s);
命名的构造函数允许从 32 位整数或字符串值创建标签,当输入无效时将返回std::nullopt
。
另请参阅 QFont::setFeature() 和QFont::featureTags()。
成员函数文档
[constexpr noexcept]
Tag::Tag()
默认构造函数,产生无效标签。
[constexpr noexcept]
template <size_t N> Tag::Tag(const char (&)[N] str)
从字符串字面意义构建标签,str 。字符串长度必须正好为四个字符。
font.setFeature("frac", 1);
另请参阅 fromString() 和fromValue()。
[static noexcept]
std::optional<QFont::Tag> Tag::fromString(QAnyStringView view)
返回由view 中的字符串构建的标签。字符串长度必须正好为四个字符。
如果输入长度不是四个字符,或生成的标记无效,则返回std::nullopt
。
[static constexpr noexcept]
std::optional<QFont::Tag> Tag::fromValue(quint32 value)
返回由value 构建的标签,如果生成的标签无效,则返回std::nullopt
。
另请参见 isValid().
[constexpr noexcept]
bool Tag::isValid() const
返回标签是否有效。如果标签值不为零,则标签有效。
另请参阅 value()、fromValue() 和fromString()。
QByteArray Tag::toString() const
以字节数组形式返回该标记的字符串表示。
另请参阅 fromString()。
[constexpr noexcept]
quint32 Tag::value() const
返回此标记的数值。
相关非会员
[constexpr noexcept]
Qt::strong_ordering compareThreeWay(const QFont::Tag &lhs, const QFont::Tag &rhs)
[constexpr noexcept]
bool comparesEqual(const QFont::Tag &lhs, const QFont::Tag &rhs)
将lhs 与rhs 进行平等和排序比较。
[constexpr noexcept]
size_t qHash(QFont::Tag key, size_t seed = 0)
返回key 的哈希值,使用seed 作为计算的种子。
© 2025 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.