TextSelection QML Type
テキストの連続した選択範囲とそのプロパティを表します。詳細...
| Import Statement: | import QtQuick |
| Since: | Qt 6.7 |
プロパティ
- alignment : enumeration
- color : color
- document : TextDocument
(since 6.11) - font : color
- selectionEnd : int
(since 6.11) - selectionStart : int
(since 6.11) - text : string
方法
- void duplicate()
(since 6.11) - void linkTo(url destination)
(since 6.11) - void moveSelectionEnd(MoveOperation op, int n)
(since 6.11) - bool moveSelectionStart(MoveOperation op, int n)
(since 6.11)
詳細説明
TextEdit.cursorSelection は、現在選択されているテキストの範囲を表します (マウスのドラッグなどによる)。これは、character やblock フォーマットのプロパティと同様に、選択されたテキストを照会および変更するために使用できます。
さらに、6.11 以降では、明示的な非ビジュアルインスタンスを作成することができます:
TextEdit { id: textEdit TextSelection { id: sel1 } }
TextEdit.cursorSelection また、明示的な TextSelection インスタンスは、character やblock 形式のプロパティだけでなく、指定されたテキスト範囲のクエリや変更にも使用できます。
注意: この 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::movePosition 、QTextCursor::KeepAnchor 、moveSelectionStart()、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.Up | 1行上に移動 |
TextSelection.Left | 左に1文字移動 |
TextSelection.WordLeft | 左に1文字移動 |
TextSelection.End | 文書の末尾に移動する。 |
TextSelection.EndOfLine | 現在の行の最後に移動する。 |
TextSelection.EndOfWord | 現在の単語の末尾に移動 |
TextSelection.EndOfBlock | 現在のブロックの末尾に移動 |
TextSelection.NextBlock | 次のブロックの先頭に移動 |
TextSelection.NextCharacter | 次の文字に移動する。 |
TextSelection.NextWord | 次の単語に移動する。 |
TextSelection.Down | 1行下に移動 |
TextSelection.Right | 右に1文字移動 |
TextSelection.WordRight | 右に1単語移動 |
TextSelection.NextCell | 現在の表内の次の表のセルの先頭に移動する。現在のセルが行の最後のセルの場合、カーソルは次の行の最初のセルに移動する。 |
TextSelection.PreviousCell | 現在の表内の前の表のセルの先頭に移動する。現在のセルが行の最初のセルの場合、カーソルは前の行の最後のセルに移動する。 |
TextSelection.NextRow | 現在の表の次の行の最初の新しいセルに移動する。 |
TextSelection.PreviousRow | 現在の表の前の行の最後のセルに移動する。 |
すべての操作が正常に完了した場合はtrue を返し、そうでない場合はfalse を返します。
このメソッドは Qt 6.11 で導入されました。
QTextCursor::movePosition 、QTextCursor::MoveAnchor 、QTextCursor::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.