Trace QML Type
Trace 是触摸输入数据的数据模型。更多
Import Statement: | import QtQuick.VirtualKeyboard |
Since: | QtQuick.VirtualKeyboard 2.0 |
In C++: | QVirtualKeyboardTrace |
属性
- canceled : bool
- channels : list<strings>
- final : bool
- opacity : real
(since QtQuick.VirtualKeyboard 2.4)
- traceId : int
方法
- int addPoint(point point)
- var channelData(string channel, int pos, int count)
- var points(int pos, int count)
- void setChannelData(int index, string channel, var data)
- void startHideTimer(int delayMs)
(since QtQuick.VirtualKeyboard.Styles 6.1)
详细描述
轨迹为坐标数据和其他与单个描边相关的可选数据提供了数据模型。
跟踪对象的典型用例如下:
- TraceInputArea 或其他输入设备通过调用 () 方法启动跟踪事件。InputEngine.traceBegin
- 如果当前输入法接受该事件,则会创建跟踪对象并配置所需的数据通道(如果有)。
- TraceInputArea 为跟踪对象收集数据。
- TraceInputArea 调用 () 方法完成跟踪,并将跟踪对象传回输入法。InputEngine.traceEnd
- 输入方法处理数据,并在不再需要时丢弃对象。
坐标数据通过points() 函数获取。
除了基于坐标的数据外,还可以为每个数据点附加任意数据通道。
数据通道必须在添加点之前定义。TraceInputArea 支持的数据通道如下:
"t"
为每个数据点收集时间。时间是自 1970/01/01 起的毫秒数:
例如,配置对象以收集每个点的时间:
QVirtualKeyboardTrace *trace = new QVirtualKeyboardTrace(this); trace->setChannels(QStringList() << "t");
可以使用channelData() 函数访问收集到的数据:
QVariantList timeData = trace->channelData("t");
跟踪对象由其创建者拥有,创建者就是正常情况下的输入法。这意味着对象是在InputMethod.traceBegin() (QML) 方法中构建的。
根据定义,跟踪对象最早可在InputMethod.traceEnd() (QML) 方法中销毁。
属性文档
canceled : bool |
该属性定义是否取消跟踪。对于canceled
属性设置为 true 的跟踪,不应处理其输入数据。
channels : list<strings> |
跟踪中的附加数据通道列表。该属性必须在添加数据前初始化。
final : bool |
该属性定义了跟踪是否可以接受更多数据。如果值为true
,则不接受更多数据。
opacity : real |
该属性定义了 Trace 的不透明程度。
值越小,跟踪越透明:0.0
为完全透明,1.0
为完全不透明。
当添加新的跟踪时,该属性可使旧跟踪更加透明。
此属性在 QtQuick.VirtualKeyboard 2.4 中引入。
traceId : int |
此跟踪的唯一 id。
方法文档
向 Trace 添加point 。
该方法返回已添加点的索引,如果无法添加点(即final 为 true),则返回-1。
注: 使用setChannelData() 函数将附加数据与点关联时需要返回索引。
从指定的channel 返回数据。如果没有给出其他参数,函数将返回所有数据。
如果给定了pos 参数,函数将返回从该位置开始的数据。count 参数限制了返回的条目数量。
另请参阅 setChannelData() 。
返回点列表。如果没有给出参数,函数将返回所有点。
如果给定pos 参数,函数将返回从位置开始的点。count 参数限制了返回点的数量。
返回的列表包含point
类型。
在给定的数据channel 中,为index 处的点设置data 。
如果不为每个数据点调用该方法,通道数据将被填充为空值。但是,不能在任意索引处添加数据,即必须与点数据同步添加。
另请参见 channelData()。
|
启动一个计时器,在delayMs 之后将不透明度设置为零。如果在delayMs 内再次调用,则重新启动计时器。
使用此函数,输入法可以在销毁跟踪对象之前从屏幕上隐藏跟踪,例如,以表明跟踪已被处理。
此方法在 QtQuick.VirtualKeyboard.Styles 6.1 中引入。
© 2025 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.