QTextListFormat Class

QTextListFormat クラスは、QTextDocument のリストのフォーマット情報を提供します

ヘッダ #include <QTextListFormat>
CMake: find_package(Qt6 REQUIRED COMPONENTS Gui)
target_link_libraries(mytarget PRIVATE Qt6::Gui)
qmake: QT += gui
継承: QTextFormat

注意:このクラスの関数はすべてリエントラントです。

パブリック型

enum Style { ListDisc, ListCircle, ListSquare, ListDecimal, ListLowerAlpha, …, ListUpperRoman }

パブリック関数

QTextListFormat()
int indent() const
bool isValid() const
QString numberPrefix() const
QString numberSuffix() const
void setIndent(int indentation)
void setNumberPrefix(const QString &numberPrefix)
void setNumberSuffix(const QString &numberSuffix)
(since 6.6) void setStart(int start)
void setStyle(QTextListFormat::Style style)
(since 6.6) int start() const
QTextListFormat::Style style() const

詳細説明

リストは、テキストブロックとして表現される1つ以上の項目から構成されます。リストの書式は、リスト内の項目の外観を指定します。特に、各項目のインデントとスタイルを決定します。

項目のインデントは、各項目が左マージンから一定量オフセットされる整数値です。この値はindent() で読み込み、setIndent() で設定する。

各項目の装飾に使用されるスタイルはsetStyle() で設定され、style() 関数で読み取ることができます。スタイルは、リスト内の項目に使用される箇条書きの種類や番号の付け方を制御します。10進数方式を使用するリストは、setStart() で上書きされていない限り、0ではなく1からカウントを開始することに注意してください。

例えば、ListNumberPrefixとListNumberSuffixプロパティを使用すると、順序付きリストで使用される数字を(1)、(2)、(3)などのようにカスタマイズすることができます:

QTextListFormat listFormat;

listFormat.setStyle(QTextListFormat::ListDecimal);
listFormat.setNumberPrefix("(");
listFormat.setNumberSuffix(")");

cursor.insertList(listFormat);

QTextListも参照のこと

メンバ型ドキュメント

enum QTextListFormat::Style

この列挙型は、リスト項目の装飾に使われる記号を記述します:

定数説明
QTextListFormat::ListDisc-1塗りつぶされた円
QTextListFormat::ListCircle-2空の円
QTextListFormat::ListSquare-3塗りつぶされた正方形
QTextListFormat::ListDecimal-4昇順の10進数
QTextListFormat::ListLowerAlpha-5アルファベット順の小文字ラテン文字
QTextListFormat::ListUpperAlpha-6アルファベット順の大文字ラテン文字
QTextListFormat::ListLowerRoman-7小文字のローマ数字(最大4999項目のみサポート)
QTextListFormat::ListUpperRoman-8大文字のローマ数字(4999項目までしかサポートしない)

メンバー関数ドキュメント

QTextListFormat::QTextListFormat()

新しいリスト・フォーマット・オブジェクトを作成します。

int QTextListFormat::indent() const

リストフォーマットのインデントを返します。このインデントにQTextDocument::indentWidth プロパティを掛けて、ピクセル単位の有効なインデントを取得します。

setIndent()も参照

bool QTextListFormat::isValid() const

このリスト形式が有効な場合はtrue を返し、そうでない場合はfalse を返す。

QString QTextListFormat::numberPrefix() const

リスト書式の番号プレフィックスを返します。

setNumberPrefix()も参照 ください。

QString QTextListFormat::numberSuffix() const

リスト書式の番号接尾辞を返します。

setNumberSuffix()も参照ください

void QTextListFormat::setIndent(int indentation)

リスト書式のindentation を設定します。インデントにQTextDocument::indentWidth プロパティを掛けると、ピクセル単位の有効なインデントが得られます。

indent()も参照

void QTextListFormat::setNumberPrefix(const QString &numberPrefix)

リスト書式の番号プレフィックスをnumberPrefix で指定した文字列に設定します。これはすべてのソートされたリスト・タイプで使用できる。ソートされていないリスト型には効果がありません。

デフォルトのプレフィックスは空文字列です。

numberPrefix()も参照

void QTextListFormat::setNumberSuffix(const QString &numberSuffix)

リスト書式の番号接尾辞をnumberSuffix で指定した文字列に設定します。これはすべてのソートされたリスト・タイプで使用できる。ソートされていないリスト型には効果がありません。

デフォルトの接尾辞は". "です。

numberSuffix()も参照

[since 6.6] void QTextListFormat::setStart(int start)

リスト・フォーマットのstart インデックスを設定する。

これにより、リストを1以外のインデックスで開始することができる。これは、すべてのソートされたリスト・タイプで使用できる。たとえば、style ()がQTextListFormat::ListLowerAlphastart ()が4 の場合、最初のリスト項目は "d "で始まる。これは、ソートされていないリスト型には効果がない。

デフォルトの開始は1 です。

この関数は Qt 6.6 で導入されました。

start()も参照してください

void QTextListFormat::setStyle(QTextListFormat::Style style)

リスト・フォーマットのstyle を設定する。

style() およびStyleも参照のこと

[since 6.6] int QTextListFormat::start() const

style() がQTextListFormat::ListDecimal の場合、または他のソートされたリスト・タイプをオフセットするために、最初のリスト・アイテムで表示される番号を返します。

この関数は Qt 6.6 で導入されました。

setStart()も参照してください

QTextListFormat::Style QTextListFormat::style() const

リスト書式のスタイルを返します。

setStyle() およびStyleも参照ください

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