QTextListFormat Class
QTextListFormat クラスは、QTextDocument 内のリストの書式設定情報を提供します。詳細...
| ヘッダー: | #include <QTextListFormat> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
| qmake: | QT += gui |
| 継承元: | QTextFormat |
- 継承されたメンバーを含むすべてのメンバーの一覧
- QTextListFormat は、リッチテキスト処理 APIおよび暗黙的に共有されるクラスの一部です。
注:このクラスのすべての関数は再入可能です。
パブリック型
| 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::ListLowerAlpha で、start() が4 の場合、リストの最初の項目は「d」から始まります。ソートされていないリスト型には何の影響もありません。
デフォルトの開始値は `1` です。
この関数は Qt 6.6 で導入されました。
start()も参照してください 。
void QTextListFormat::setStyle(QTextListFormat::Style style)
リスト形式のstyle を設定します。
[since 6.6] int QTextListFormat::start() const
style() の引数が `QTextListFormat::ListDecimal` の場合、最初のリスト項目に表示される番号を返します。また、他のソート済みリスト型に対してはオフセットを返します。
この関数は Qt 6.6 で導入されました。
setStart()も参照してください 。
QTextListFormat::Style QTextListFormat::style() const
リスト形式のスタイルを返します。
© 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.