このページでは

TextSelection QML Type

テキストの連続した選択範囲とそのプロパティを表します。詳細...

Import Statement: import QtQuick
Since: Qt 6.7

プロパティ

方法

詳細説明

TextEdit.cursorSelection は、現在選択されているテキストの範囲を表します (マウスのドラッグなどによる)。これは、characterblock フォーマットのプロパティと同様に、選択されたテキストを照会および変更するために使用できます。

さらに、6.11 以降では、明示的な非ビジュアルインスタンスを作成することができます:

TextEdit {
    id: textEdit

    TextSelection {
        id: sel1
    }
}

TextEdit.cursorSelection また、明示的な TextSelection インスタンスは、characterblock 形式のプロパティだけでなく、指定されたテキスト範囲のクエリや変更にも使用できます。

注意: この API は技術プレビューであり、Qt の将来のバージョンで変更または削除される可能性があります。

TextEdit およびQTextCursorも参照して ください。

プロパティのドキュメント

alignment : enumeration

選択テ キ ス ト を含むブ ロ ッ ク の整列。

QTextBlockFormat::alignment()も参照

color : color

選択テキス ト の前景色。

QTextCharFormat::foreground()も参照

document : TextDocument [since 6.11]

選択されたテキストを含むQQuickTextDocument

このプロパティは Qt 6.11 で導入されました。

QtQuick::TextEdit::textDocumentも参照してください

font : color

選択テキストのフォント。

QTextCharFormat::font()も参照

selectionEnd : int [since 6.11]

選択範囲の最後の文字の後の位置。

このプロパティは Qt 6.11 で導入されました。

QtQuick::TextEdit::selectionEndも参照してください

selectionStart : int [since 6.11]

選択範囲の最初の文字の前の位置。

このプロパティは Qt 6.11 で導入されました。

QtQuick::TextEdit::selectionStartも参照してください

text : string

リッチテキストマークアップのない選択テキスト。

このプロパティを設定すると、選択されたテキストが指定された文字列に置き換えられます。

メソッドのドキュメント

[since 6.11] void duplicate()

選択したテキストを前方にコピーし、すべての書式をコピーにそのまま残し、コピーを選択範囲として終了します。

たとえば、行全体が選択されている場合、この関数はその行のコピーをすぐ下に挿入し、そのコピーを選択します。単語が選択されている場合、この関数はその単語を右にコピーして選択します。

このメソッドは Qt 6.11 で導入されました。

[since 6.11] void linkTo(url destination)

選択したテキストからdestination へのハイパーリンクを作成します。

このメソッドは Qt 6.11 で導入されました。

QTextCharFormat::setAnchorHref()も参照してください

[since 6.11] void moveSelectionEnd(MoveOperation op, int n)

moveSelectionStart() で使用されている列挙値の1つであるop に従って、selectionEnd n 回移動する。

moveSelectionStart() が直前に呼ばれた場合、selectionEnd == selectionStart 、そこからこの関数が移動し、テキストの範囲が選択されるようになります。

このメソッドは Qt 6.11 で導入されました。

QTextCursor::movePositionQTextCursor::KeepAnchormoveSelectionStart()、QTextCursor::MoveOperationも参照してください

[since 6.11] bool moveSelectionStart(MoveOperation op, int n)

テキストの選択を解除し、op に従ってselectionStart n 回移動する:

定数説明
TextSelection.NoMoveカーソルをそのままにする
TextSelection.Startドキュメントの先頭に移動する。
TextSelection.StartOfLine現在の行の先頭に移動する。
TextSelection.StartOfBlock現在のブロックの先頭に移動する。
TextSelection.StartOfWord現在の単語の先頭に移動する。
TextSelection.PreviousBlock前のブロックの先頭に移動する。
TextSelection.PreviousCharacter前の文字に移動する。
TextSelection.PreviousWord前の単語の先頭に移動
TextSelection.Up1行上に移動
TextSelection.Left左に1文字移動
TextSelection.WordLeft左に1文字移動
TextSelection.End文書の末尾に移動する。
TextSelection.EndOfLine現在の行の最後に移動する。
TextSelection.EndOfWord現在の単語の末尾に移動
TextSelection.EndOfBlock現在のブロックの末尾に移動
TextSelection.NextBlock次のブロックの先頭に移動
TextSelection.NextCharacter次の文字に移動する。
TextSelection.NextWord次の単語に移動する。
TextSelection.Down1行下に移動
TextSelection.Right右に1文字移動
TextSelection.WordRight右に1単語移動
TextSelection.NextCell現在の表内の次の表のセルの先頭に移動する。現在のセルが行の最後のセルの場合、カーソルは次の行の最初のセルに移動する。
TextSelection.PreviousCell現在の表内の前の表のセルの先頭に移動する。現在のセルが行の最初のセルの場合、カーソルは前の行の最後のセルに移動する。
TextSelection.NextRow現在の表の次の行の最初の新しいセルに移動する。
TextSelection.PreviousRow現在の表の前の行の最後のセルに移動する。

すべての操作が正常に完了した場合はtrue を返し、そうでない場合はfalse を返します。

このメソッドは Qt 6.11 で導入されました。

QTextCursor::movePositionQTextCursor::MoveAnchorQTextCursor::MoveOperationも参照して ください。

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