QTextList Class
QTextListクラスは、QTextDocument の項目の装飾されたリストを提供します。
ヘッダ | #include <QTextList> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
継承: | QTextBlockGroup |
- 継承メンバを含む全メンバのリスト
- QTextList はRich Text Processing API の一部です。
注意:このクラスの関数はすべてリエントラントです。
パブリック関数
void | add(const QTextBlock &block) |
int | count() const |
QTextListFormat | format() const |
QTextBlock | item(int i) const |
int | itemNumber(const QTextBlock &block) const |
QString | itemText(const QTextBlock &block) const |
void | remove(const QTextBlock &block) |
void | removeItem(int i) |
void | setFormat(const QTextListFormat &format) |
詳細説明
リストには一連のテキストブロックが含まれ、各ブロックには箇条書きなどの記号が付けられています。複数のレベルのリストを使用することができ、自動番号付け機能により、数値順リストやアルファベット順リストをサポートします。
リ ス ト は、 テ キ ス ト カー ソルを使っ て現在の位置に空の リ ス ト を挿入す る か、 既存のテ キ ス ト を新 し い リ ス ト に移動す る こ と に よ っ て作成 さ れます。QTextCursor::insertList ()関数は、カーソル位置の文書に空のブロックを挿入し、それをリストの最初の項目にします。
QTextListFormat listFormat; if (list) { listFormat = list->format(); listFormat.setIndent(listFormat.indent() + 1); } listFormat.setStyle(QTextListFormat::ListDisc); cursor.insertList(listFormat);
QTextCursor::createList ()関数は、カーソルの現在のブロックの内容を取り、それを新しいリストの最初の項目にします。
カーソルの現在のリストは、QTextCursor::currentList ()で見つけることができる。
リスト内の項目数は、count ()で与えられる。各項目は、item() 関数を使用して、リスト内のインデックスで取得できる。同様に、指定した項目のインデックスはitemNumber() で求めることができる。各項目のテキストは、itemText() 関数で取得できます。
リスト内の項目は、文書内で隣接する要素とは限らないことに注意。た と えば、 複数階層の リ ス ト の最上位階層の項目は、 その下位階層の項目で区切られます。
リストの項目は、removeItem() 関数でインデックスごとに削除することができます。remove() は、リスト内の指定された項目を削除します。
リストの書式はsetFormat() で設定し、format() で読み込む。書式は、個々の項目ではなく、リスト自体の装飾を表します。
QTextBlock 、QTextListFormat 、QTextCursorも参照のこと 。
メンバ関数ドキュメント
void QTextList::add(const QTextBlock &block)
与えられたblock をリストの一部にする。
remove() およびremoveItem()も参照 。
int QTextList::count() const
リストに含まれる項目の数を返します。
QTextListFormat QTextList::format() const
リストの書式を返します。
setFormat()も参照 。
QTextBlock QTextList::item(int i) const
リスト内のi-番目のテキスト・ブロックを返す。
int QTextList::itemNumber(const QTextBlock &block) const
与えられたblock に対応するリスト項目のインデックスを返す。ブロックがリストに存在しない場合は -1 を返します。
QString QTextList::itemText(const QTextBlock &block) const
与えられたblock に対応するリスト項目のテキストを返す。
void QTextList::remove(const QTextBlock &block)
与えられたblock をリストから削除します。
add() およびremoveItem()も参照 ください。
void QTextList::removeItem(int i)
項目位置i の項目をリストから削除する。リストの最後の項目が削除されると、リストを所有するQTextDocument によってリストは自動的に削除されます。
void QTextList::setFormat(const QTextListFormat &format)
リストの書式をformat に設定する。
format()も参照のこと 。
© 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.