QTextBoundaryFinder Class
QTextBoundaryFinder クラスは、文字列内の Unicode テキスト境界を検出する方法を提供します。詳細...
| ヘッダー: | #include <QTextBoundaryFinder> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
- 継承されたメンバーを含むすべてのメンバーの一覧
- QTextBoundaryFinder は、「暗黙的に共有されるクラス」および「文字列データ用クラス」の一部です。
注:このクラスのすべての関数は再入可能です。
パブリック型
| enum | BoundaryReason { NotAtBoundary, BreakOpportunity, StartOfItem, EndOfItem, MandatoryBreak, SoftHyphen } |
| flags | BoundaryReasons |
| enum | BoundaryType { Grapheme, Word, Line, Sentence } |
パブリック関数
| QTextBoundaryFinder() | |
| QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QString &string) | |
(since 6.0) | QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, QStringView string, unsigned char *buffer = nullptr, qsizetype bufferSize = 0) |
| QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QChar *chars, qsizetype length, unsigned char *buffer = nullptr, qsizetype bufferSize = 0) | |
| QTextBoundaryFinder(const QTextBoundaryFinder &other) | |
(since 6.11) | QTextBoundaryFinder(QTextBoundaryFinder &&other) |
| ~QTextBoundaryFinder() | |
| QTextBoundaryFinder::BoundaryReasons | boundaryReasons() const |
| bool | isAtBoundary() const |
| bool | isValid() const |
| qsizetype | position() const |
| void | setPosition(qsizetype position) |
| QString | string() const |
(since 6.11) void | swap(QTextBoundaryFinder &other) |
| void | toEnd() |
| qsizetype | toNextBoundary() |
| qsizetype | toPreviousBoundary() |
| void | toStart() |
| QTextBoundaryFinder::BoundaryType | type() const |
(since 6.11) QTextBoundaryFinder & | operator=(QTextBoundaryFinder &&other) |
| QTextBoundaryFinder & | operator=(const QTextBoundaryFinder &other) |
詳細な説明
QTextBoundaryFinder を使用すると、Unicode テキスト境界仕様(Unicode 標準付属書 #14およびUnicode 標準付属書 #29 を参照)に従って、文字列内の Unicode テキスト境界を検索することができます。
QTextBoundaryFinder は、BoundaryType の値に応じて、4 つのモードでQString を操作することができます。
ユーザーが 1 つの文字、あるいは言語の基本単位として認識する Unicode 文字の単位は、ここでは「グラフエム・クラスター」と呼ばれます。 たとえば、2 つの Unicode 文字「A」とダイアレシスは、ユーザーが 1 つの文字として認識するため、1 つのグラフエム・クラスターを形成しますが、この場合は 2 つの Unicode コードポイントによって表されます(https://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundariesを参照)によって2つのUnicodeコードポイントで表現されます。Grapheme_Cluster_Boundariesを参照)。
単語の境界は、その言語において単語とみなされるものの開始点と終了点を特定するために設けられています(https://www.unicode.org/reports/tr29/#Word_Boundariesを参照)。
改行境界は、改行が行われる可能性のある位置を示し、文境界は文全体の開始位置と終了位置を示します(https://www.unicode.org/reports/tr29/#Sentence_Boundariesおよびhttps://www.unicode.org/reports/tr14/ を参照)。
文字列の最初の位置は常に有効な境界であり、最初の文字の直前の位置を指します。また、文字列の長さに相当する最後の位置も有効であり、最後の文字の直後の位置を指します。
メンバ型のドキュメント
enum QTextBoundaryFinder::BoundaryReason
flags QTextBoundaryFinder::BoundaryReasons
| 定数 | 値 | 説明 |
|---|---|---|
QTextBoundaryFinder::NotAtBoundary | 0 | 境界検出器は境界位置にありません。 |
QTextBoundaryFinder::BreakOpportunity | 0x1f | 境界検出器が改行候補位置にあります。このような改行候補は、項目境界(StartOfItem、EndOfItem、またはその両方)、必須の改行、あるいはソフトハイフンの可能性もあります。 |
QTextBoundaryFinder::StartOfItem (since Qt 5.0) | 0x20 | 境界検出子が、グラフェム、単語、文、または行の先頭にあります。 |
QTextBoundaryFinder::EndOfItem (since Qt 5.0) | 0x40 | 境界検出器が、グラフェム、単語、文、または行の末尾に位置しています。 |
QTextBoundaryFinder::MandatoryBreak (since Qt 5.0) | 0x80 | 境界検出器が行の末尾にあります(行境界タイプでのみ発生します)。 |
QTextBoundaryFinder::SoftHyphen | 0x100 | 境界検出器はソフトハイフンの位置にあります(行境界タイプでのみ発生します)。 |
BoundaryReasons 型は、QFlags<BoundaryReason> の typedef です。これは、BoundaryReason 値の論理和(OR)の組み合わせを格納します。
enum QTextBoundaryFinder::BoundaryType
| 定数 | 値 | 説明 |
|---|---|---|
QTextBoundaryFinder::Grapheme | 0 | 最小の境界となる文字単位を検索します。これには、文字、句読点、数字などが含まれます。 |
QTextBoundaryFinder::Word | 1 | 単語を検索します。 |
QTextBoundaryFinder::Line | 3 | テキストを複数行に分割するための候補位置を特定します。 |
QTextBoundaryFinder::Sentence | 2 | 文の区切りを検出します。これには、ピリオドや疑問符などが含まれます。 |
メンバー関数のドキュメント
QTextBoundaryFinder::QTextBoundaryFinder()
無効な QTextBoundaryFinder オブジェクトを生成します。
QTextBoundaryFinder::QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QString &string)
string を操作対象とする、type の QTextBoundaryFinder オブジェクトを作成します。
[since 6.0] QTextBoundaryFinder::QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, QStringView string, unsigned char *buffer = nullptr, qsizetype bufferSize = 0)
string を操作する、type の QTextBoundaryFinder オブジェクトを作成します。
buffer bufferSize サイズのオプションの作業用バッファで、QTextBoundaryFinder に渡すことができます。バッファが、必要な作業データを格納するのに十分な大きさである場合(bufferSize >= length + 1)、QTextBoundaryFinder は独自のバッファを割り当てる代わりに、このバッファを使用します。
警告: QTextBoundaryFinder は string のコピーを作成しません。QTextBoundaryFinder オブジェクトが存続している間、この配列が確保されたままであることを保証するのは、アプリケーション開発者の責任です。buffer についても同様です。
この関数は Qt 6.0 で導入されました。
QTextBoundaryFinder::QTextBoundaryFinder(QTextBoundaryFinder::BoundaryType type, const QChar *chars, qsizetype length, unsigned char *buffer = nullptr, qsizetype bufferSize = 0)
QTextBoundaryFinder(type,QStringView(chars, length), buffer, bufferSize) と同じです。
これはオーバーロードされた関数です。
QTextBoundaryFinder::QTextBoundaryFinder(const QTextBoundaryFinder &other)
QTextBoundaryFinder オブジェクト(other )をコピーします。
[noexcept, since 6.11] QTextBoundaryFinder::QTextBoundaryFinder(QTextBoundaryFinder &&other)
other から新しい QTextBoundaryFinder を move-construct します。
注: 移動元のオブジェクト `other`は 、部分的に形成された状態になります。この状態では、有効な操作は破棄と新しい値への代入のみです。
この関数は Qt 6.11 で導入されました。
[noexcept] QTextBoundaryFinder::~QTextBoundaryFinder()
QTextBoundaryFinder オブジェクトを破棄します。
QTextBoundaryFinder::BoundaryReasons QTextBoundaryFinder::boundaryReasons() const
境界検出機能が現在の位置を境界として選択した理由を返します。
bool QTextBoundaryFinder::isAtBoundary() const
オブジェクトのposition()が現在、有効なテキスト境界にある場合、true を返します。
bool QTextBoundaryFinder::isValid() const
テキスト境界検出器が有効な場合はtrue を返し、そうでない場合はfalse を返します。デフォルトのQTextBoundaryFinder は無効です。
qsizetype QTextBoundaryFinder::position() const
QTextBoundaryFinder の現在の位置を返します。
範囲は 0(文字列の先頭)から文字列の長さまで(長さを含む)です。
setPosition()も参照してください 。
void QTextBoundaryFinder::setPosition(qsizetype position)
QTextBoundaryFinder の現在の位置をposition に設定します。
position が範囲外の場合、有効な位置の範囲内に制限されます。この場合、有効な位置は 0 から文字列の長さまで(端数を含む)となります。
position()も参照してください 。
QString QTextBoundaryFinder::string() const
QTextBoundaryFinder オブジェクトが操作対象とする文字列を返します。
[noexcept, since 6.11] void QTextBoundaryFinder::swap(QTextBoundaryFinder &other)
このテキスト境界検出機能をother に置き換えます。この処理は非常に高速で、失敗することはありません。
この関数は Qt 6.11 で導入されました。
void QTextBoundaryFinder::toEnd()
ファインダーを文字列の末尾に移動します。これは、setPosition (string.length())と同等です。
setPosition() およびposition()も参照してください 。
qsizetype QTextBoundaryFinder::toNextBoundary()
QTextBoundaryFinder を次の境界位置に移動させ、その位置を返します。
次の境界が存在しない場合は -1 を返します。
qsizetype QTextBoundaryFinder::toPreviousBoundary()
QTextBoundaryFinder を直前の境界位置に移動させ、その位置を返します。
直前の境界が存在しない場合は -1 を返します。
void QTextBoundaryFinder::toStart()
ファインダーを文字列の先頭に移動します。これは、setPosition(0) と同じ動作です。
setPosition() およびposition()も参照してください 。
QTextBoundaryFinder::BoundaryType QTextBoundaryFinder::type() const
QTextBoundaryFinder の型を返します。
[noexcept, since 6.11] QTextBoundaryFinder &QTextBoundaryFinder::operator=(QTextBoundaryFinder &&other)
other をこのQTextBoundaryFinder インスタンスにムーブ代入します。
注: 移動元のオブジェクト `other`は 、部分的に形成された状態となり、この状態では破棄と新しい値の代入のみが有効な操作となります。
この関数は Qt 6.11 で導入されました。
QTextBoundaryFinder &QTextBoundaryFinder::operator=(const QTextBoundaryFinder &other)
オブジェクト「other 」を、別のQTextBoundaryFinder オブジェクトに割り当てます。
© 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.