PdfSelection QML Type
PDF 文档中文本选择的表示。更多
| Import Statement: | import QtQuick.Pdf |
| Inherits: |
属性
- document : PdfDocument
- from : point
- geometry : list<list<point>>
- hold : bool
- page : int
- renderScale : real
- text : string
- to : point
方法
- void clear()
- void copyToClipboard()
- void selectAll()
详细说明
PdfSelection提供了文本字符串及其在边界框内从一点到另一点的几何形状。
要使用鼠标修改选区,将from 和to 与输入处理程序的适当属性绑定,使其分别设置为拖动手势开始和结束的位置;绑定hold 属性,使其在拖动手势期间设置为true ,在手势结束时设置为false 。
PdfSelection还能直接处理输入法查询,以便在iOS等平台上使用文本选择句柄。为此,它必须有键盘焦点。
属性文档
document : PdfDocument
该属性用于保存要选择文本的 PDF 文档。
from : point
从页面左上角开始选择文本的起始位置(以像素为单位)。DragHandler 例如,可以将其与centroid.pressPosition 绑定,以便从用户按下鼠标按钮并开始拖动的位置开始选择文本。
geometry : list<list<point>>
表格中的一组路径,可绑定到PathMultiline 实例的paths 属性,以在选区中包含的文本区域周围渲染一批矩形:
PdfDocument {
id: doc
}
PdfSelection {
id: selection
document: doc
from: textSelectionDrag.centroid.pressPosition
to: textSelectionDrag.centroid.position
hold: !textSelectionDrag.active
}
Shape {
ShapePath {
PathMultiline {
paths: selection.geometry
}
}
}
DragHandler {
id: textSelectionDrag
acceptedDevices: PointerDevice.Mouse | PointerDevice.Stylus
target: null
}另请参阅 PathMultiline 。
hold : bool
控制在from 和to 发生变化时是否保持现有选择。释放鼠标或触摸点时,可将此属性设置为true ,这样就不会因点绑定发生变化而丢失选择。
page : int
要搜索的页码。
另请参阅 QtQuick::Image::currentFrame 。
renderScale : real
页面渲染时点与像素的比率。
它用于缩放from 和to ,以查找文档中选定字符的范围,因为文档中的位置总是以点为单位。
text : string
在from 和to 之间的矩形区域中找到的文本,或page 上的所有文本(如果调用了selectAll() )。
to : point
从页面左上角开始查找所选文本的结束位置(以像素为单位)。例如,可以将其绑定到DragHandler 的centroid.position ,以便在用户当前拖动鼠标的位置结束文本选择。
方法文档
void clear()
清除当前选择。
void copyToClipboard()
将text 属性中的纯文本复制到系统剪贴板。
void selectAll()
选择当前page 上的所有文本。
© 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.