このページでは

QFont::Tag Struct

struct QFont::Tag

QFont::Tag 型を使用すると、フォントの高度な機能を利用できます。詳細...

この構造体は Qt 6.7 で導入されました。

パブリック関数

Tag()
Tag(const char (&str)[N])
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)
QDataStream &operator<<(QDataStream &, QFont::Tag)
QDataStream &operator>>(QDataStream &, QFont::Tag &)

詳細な説明

QFont は、テキストの整形時に高度な機能へのアクセスを提供します。機能はタグによって定義され、タグは4文字の文字列、または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 default] Tag::Tag()

デフォルトコンストラクタ。無効なタグを生成する。

[constexpr noexcept] template <size_t N> Tag::Tag(const char (&str)[N])

文字列リテラル `str` からタグを作成します。リテラルは正確に 4 文字でなければなりません。

font.setFeature("frac", 1);

fromString() およびfromValue()も参照してください 。

[static noexcept] std::optional<QFont::Tag> Tag::fromString(QAnyStringView view)

view に指定された文字列から構成されたタグを返します。この文字列は、正確に4文字でなければなりません。

入力の文字数が4文字でない場合、または生成されるタグが無効となる場合は、std::nullopt を返します。

isValid() およびfromValue()も参照してください 。

[static constexpr noexcept] std::optional<QFont::Tag> Tag::fromValue(quint32 value)

value から生成されたタグを返します。生成されるタグが無効な場合は、std::nullopt を返します。

isValid()も参照してください 。

[constexpr noexcept] bool Tag::isValid() const

そのタグが有効かどうかを返します。タグの値が 0 でない場合、そのタグは有効です。

value()、fromValue()、およびfromString()も参照してください 。

QByteArray Tag::toString() const

このタグの文字列表現をバイト配列として返します。

fromString()も参照してください 。

[constexpr noexcept] quint32 Tag::value() const

このタグの数値を返します。

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 とrhs を比較し、等価性と順序関係を確認してください。

[constexpr noexcept] size_t qHash(QFont::Tag key, size_t seed = 0)

`key` のハッシュ値を返し、計算のシードとして `seed ` を使用します。

QFont::Tag 用のデータストリーム演算子。

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