The QFont::Tag type provides access to advanced font features. 更多...
This struct was introduced in 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 provides access to advanced features when shaping text. A feature is defined by a tag, which can be represented as a four-character string, or as a 32bit integer value. This type represents such a tag in a type-safe way. It can be constructed from a four-character, 8bit string literal, or from a corresponding 32bit integer value. Using a shorter or longer string literal will result in a compile-time error.
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);
The named constructors allow to create a tag from an 32bit integer or string value, and will return a
std::nullopt
when the input is invalid.
另请参阅 QFont::setFeature () 和 QFont::featureTags ().
[constexpr noexcept]
Tag::
Tag
()
Default constructor, producing an invalid tag.
[constexpr noexcept]
template <size_t N> Tag::
Tag
(const
char
(&)[
N
]
str
)
Constructs a tag from a string literal, str . The literal must be exactly four characters long.
font.setFeature("frac", 1);
另请参阅 fromString () 和 fromValue ().
[static noexcept]
std::optional
<
QFont::Tag
> Tag::
fromString
(
QAnyStringView
view
)
Returns a tag constructed from the string in view . The string must be exactly four characters long.
返回
std::nullopt
if the input is not four characters long, or if the tag produced would be invalid.
另请参阅 isValid () 和 fromValue ().
[static constexpr noexcept]
std::optional
<
QFont::Tag
> Tag::
fromValue
(
quint32
value
)
Returns a tag constructed from
value
,或
std::nullopt
if the tag produced would be invalid.
另请参阅 isValid ().
[constexpr noexcept]
bool
Tag::
isValid
() const
Returns whether the tag is valid. A tag is valid if its value is not zero.
另请参阅 value (), fromValue (),和 fromString ().
Returns the string representation of this tag as a byte array.
另请参阅 fromString ().
[constexpr noexcept]
quint32
Tag::
value
() const
Returns the numerical value of this tag.
另请参阅 isValid () 和 fromValue ().
[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 with rhs for equality and ordering.
[constexpr noexcept]
size_t
qHash
(
QFont::Tag
key
,
size_t
seed
= 0)
返回哈希值为 key ,使用 seed 做计算种子。