QTextFragment Class
QTextFragment クラスは、QTextDocument のテキストをQTextCharFormat で保持します。さらに...
ヘッダー | #include <QTextFragment> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Gui) target_link_libraries(mytarget PRIVATE Qt6::Gui) |
qmake: | QT += gui |
- 継承メンバを含む全メンバ一覧
- QTextFragmentはリッチテキスト処理APIの一部です。
注意:このクラスの関数はすべてリエントラントです。
パブリック関数
QTextFragment() | |
QTextFragment(const QTextFragment &other) | |
QTextCharFormat | charFormat() const |
int | charFormatIndex() const |
bool | contains(int position) const |
QList<QGlyphRun> | glyphRuns(int pos = -1, int len = -1) const |
bool | isValid() const |
int | length() const |
int | position() const |
QString | text() const |
bool | operator!=(const QTextFragment &other) const |
bool | operator<(const QTextFragment &other) const |
QTextFragment & | operator=(const QTextFragment &other) |
bool | operator==(const QTextFragment &other) const |
詳細説明
テキストフラグメントは、単一の文字書式で保存されたテキストの一部を記述します。文字書式が変化するテキストは、異なる書式を持つテキストフラグメントのシーケンスで表すことができます。
ユーザーがフラグメント内のテキストを編集し、異なる文字書式を導入すると、書式が変更される各ポイントでフラグメントのテキストが分割され、新しいフラグメントが作成されます。たとえば、文の途中でテキストのスタイルを変更すると、フラグメントは 3 つの別々のフラグメントに分割されます。最初のフラグメントには文頭のテキストが含まれ、2番目には文中のテキストが含まれ、3番目には文末のテキストが含まれます。
フラグメントのテキストと文字書式は、text() およびcharFormat() 関数で取得できます。length() 関数は、フラグメント内のテキストの長さを指定します。position() は、フラグメントの開始位置をドキュメント内で指定します。フラグメントが文書内の特定の位置にあるかどうかを調べるには、contains() 関数を使用します。
QTextDocument およびRich Text Document Structureも参照 。
メンバ関数ドキュメント
QTextFragment::QTextFragment()
新しい空のテキストフラグメントを作成します。
QTextFragment::QTextFragment(const QTextFragment &other)
other テキス ト 断片の内容 (テキス ト と 書式) を、 こ のテキス ト 断片に複製 し ます。
QTextCharFormat QTextFragment::charFormat() const
テキスト断片の文字書式を返します。
text()も参照ください 。
int QTextFragment::charFormatIndex() const
テキスト片の文字書式に対する、文書内部の文字書式リストへのインデックスを返します。
QTextDocument::allFormats()も参照 ください。
bool QTextFragment::contains(int position) const
テ キ ス ト 断片が、 文書内の指定 さ れたposition にテ キ ス ト を含んでい る と き はtrue
を返し、 そ う でない と き はfalse
を返す。
QList<QGlyphRun> QTextFragment::glyphRuns(int pos = -1, int len = -1) const
こ のテ キ ス ト 断片の位置pos か ら 始ま るlen キ ャ ラ ク タ に対応す る グ リ フ を返 し ます。グ リ フの位置は、QTextBlock の レ イ ア ウ ト 位置に対す る 相対位置です。
pos が 0 よ り 小 さ い と き は、 デ フ ォ ル ト 値はQTextFragment の開始位置 と な り ます。len が 0 よ り 小 さ い と き は、 デ フ ォ ル ト 値はテ キ ス ト 断片の長 さ と な り ます。
QGlyphRun 、QTextBlock::layout()、QTextLayout::position()、QPainter::drawGlyphRun()も参照のこと 。
bool QTextFragment::isValid() const
こ れが有効なテ キ ス ト 断片であ る (すなわち、 文書内で有効な位置を持っ てい る) な らtrue
を返し、 そ う でないな らfalse
を返す。
int QTextFragment::length() const
テキスト片の文字数を返します。
text()も参照 。
int QTextFragment::position() const
ドキュメント内でのこのテキスト片の位置を返します。
QString QTextFragment::text() const
テキストをプレーンテキストで返します。
length() およびcharFormat()も参照 ください。
bool QTextFragment::operator!=(const QTextFragment &other) const
こ のテ キ ス ト 断片がother テ キ ス ト 断片 と 異な る (位置が異な る) と き はtrue
を返し、 そ う でなければ false を返す。
bool QTextFragment::operator<(const QTextFragment &other) const
こ のテ キ ス ト 断片がother テ キ ス ト 断片 よ り も 文書内で先に現れ る と き はtrue
を返し、 そ う でなければfalse
を返す。
QTextFragment &QTextFragment::operator=(const QTextFragment &other)
other テキス ト 断片の内容 (テキス ト と 書式) を こ のテキス ト 断片に割 り 当て ます。
bool QTextFragment::operator==(const QTextFragment &other) const
こ のテ キ ス ト 断片がother テ キ ス ト 断片 と 同 じ (同 じ 位置にあ る) な らtrue
を返し、 そ う でないな らfalse
を返す。
© 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.