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)
`selectionEnd ` を、`op` に基づいて `n ` 回移動させます。これは、`moveSelectionStart()` で使用される列挙型の値の一つです。
直前に `moveSelectionStart()` が呼び出されていた場合、`selectionEnd == selectionStart` となり、この関数はそこからオブジェクトを移動させ、テキストの範囲が選択されるようにします。
このメソッドは Qt 6.11 で導入されました。
QTextCursor::movePosition 、QTextCursor::KeepAnchor 、moveSelectionStart()、およびQTextCursor::MoveOperationも参照してください 。
[since 6.11] bool moveSelectionStart(MoveOperation op, int n)
テキストの選択を解除し、`selectionStart ` を `op` に従って `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.