TextSelection QML Type
Representa una selección contigua de texto y sus propiedades. Más...
| Import Statement: | import QtQuick |
| Since: | Qt 6.7 |
Propiedades
- alignment : enumeration
- color : color
- document : TextDocument
(since 6.11) - font : color
- selectionEnd : int
(since 6.11) - selectionStart : int
(since 6.11) - text : string
Métodos
- 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)
Descripción detallada
TextEdit.cursorSelection representa el rango de texto que está actualmente seleccionado (por ejemplo, arrastrando el ratón). Puede utilizarse para consultar y modificar el texto seleccionado, así como propiedades en los formatos character y block.
Además, desde 6.11 es posible crear instancias explícitas no visuales:
TextEdit { id: textEdit TextSelection { id: sel1 } }
TextEdit.cursorSelection y cualquier instancia TextSelection explícita puede utilizarse para consultar y modificar los rangos de texto especificados, así como propiedades en los formatos character y block.
Nota: Esta API se considera tech preview y puede cambiar o ser eliminada en futuras versiones de Qt.
Véase también TextEdit y QTextCursor.
Documentación de propiedades
alignment : enumeration
La alineación del bloque que contiene el texto seleccionado.
Véase también QTextBlockFormat::alignment().
color : color
El color de primer plano del texto seleccionado.
Véase también QTextCharFormat::foreground().
document : TextDocument [since 6.11]
El QQuickTextDocument que contiene el texto seleccionado.
Esta propiedad se introdujo en Qt 6.11.
Véase también QtQuick::TextEdit::textDocument.
font : color
El tipo de letra del texto seleccionado.
Véase también QTextCharFormat::font().
selectionEnd : int [since 6.11]
La posición después del último carácter en la selección.
Esta propiedad se introdujo en Qt 6.11.
Véase también QtQuick::TextEdit::selectionEnd.
selectionStart : int [since 6.11]
La posición antes del primer carácter en la selección.
Esta propiedad se introdujo en Qt 6.11.
Véase también QtQuick::TextEdit::selectionStart.
text : string
El texto seleccionado, sin ninguna marca de texto enriquecido.
Al establecer esta propiedad se sustituye el texto seleccionado por la cadena dada.
Documentación del método
[since 6.11] void duplicate()
Copia el texto seleccionado hacia adelante, manteniendo todo el formato intacto en la copia, y termina con la copia como selección.
Por ejemplo, si se selecciona una línea entera, esta función inserta una copia de esa línea inmediatamente debajo, y selecciona la copia. Si se selecciona una palabra, esta función la copia a la derecha y la selecciona.
Este método se introdujo en Qt 6.11.
[since 6.11] void linkTo(url destination)
Crea un hipervínculo desde el texto seleccionado a destination.
Este método se introdujo en Qt 6.11.
Véase también QTextCharFormat::setAnchorHref().
[since 6.11] void moveSelectionEnd(MoveOperation op, int n)
Mueve selectionEnd n veces de acuerdo a op, que es uno de los valores enum como se usa en moveSelectionStart().
Si moveSelectionStart() fue llamado inmediatamente antes, selectionEnd == selectionStart, y esta función lo mueve desde allí para que un rango de texto quede seleccionado.
Este método se introdujo en Qt 6.11.
Ver también QTextCursor::movePosition, QTextCursor::KeepAnchor, moveSelectionStart(), y QTextCursor::MoveOperation.
[since 6.11] bool moveSelectionStart(MoveOperation op, int n)
Deselecciona el texto y mueve selectionStart n veces según op, que es uno de los siguientes valores enum:
| Constante | Descripción |
|---|---|
TextSelection.NoMove | Mantener el cursor donde está |
TextSelection.Start | Mover al principio del documento. |
TextSelection.StartOfLine | Mover al principio de la línea actual. |
TextSelection.StartOfBlock | Mover al principio del bloque actual. |
TextSelection.StartOfWord | Ir al principio de la palabra actual. |
TextSelection.PreviousBlock | Ir al principio del bloque anterior. |
TextSelection.PreviousCharacter | Desplazarse al carácter anterior. |
TextSelection.PreviousWord | Ir al principio de la palabra anterior. |
TextSelection.Up | Subir una línea. |
TextSelection.Left | Mover un carácter a la izquierda. |
TextSelection.WordLeft | Desplazarse una palabra a la izquierda. |
TextSelection.End | Desplazarse al final del documento. |
TextSelection.EndOfLine | Ir al final de la línea actual. |
TextSelection.EndOfWord | Desplazarse al final de la palabra actual. |
TextSelection.EndOfBlock | Desplazarse al final del bloque actual. |
TextSelection.NextBlock | Pasar al principio del bloque siguiente. |
TextSelection.NextCharacter | Pasar al carácter siguiente. |
TextSelection.NextWord | Pasar a la palabra siguiente. |
TextSelection.Down | Bajar una línea. |
TextSelection.Right | Desplazarse un carácter a la derecha. |
TextSelection.WordRight | Desplazarse una palabra a la derecha. |
TextSelection.NextCell | Moverse al principio de la siguiente celda de la tabla dentro de la tabla actual. Si la celda actual es la última de la fila, el cursor se moverá a la primera celda de la fila siguiente. |
TextSelection.PreviousCell | Moverse al principio de la celda de la tabla anterior dentro de la tabla actual. Si la celda actual es la primera celda de la fila, el cursor se moverá a la última celda de la fila anterior. |
TextSelection.NextRow | Moverse a la primera nueva celda de la siguiente fila dentro de la tabla actual. |
TextSelection.PreviousRow | Mover a la última celda de la fila anterior en la tabla actual. |
Devuelve true si todas las operaciones se han completado con éxito; en caso contrario devuelve false.
Este método se introdujo en Qt 6.11.
Véase también QTextCursor::movePosition, QTextCursor::MoveAnchor, y 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.