Trace QML Type

跟踪是用于触摸输入数据的数据模型。 更多...

import 语句: import QtQuick.VirtualKeyboard
Since: QtQuick.VirtualKeyboard 2.0
实例化: QVirtualKeyboardTrace

特性

方法

详细描述

跟踪为坐标数据和单个笔画关联的其它可选数据,提供数据模型。

跟踪对象的典型用例如下:

  • TraceInputArea (或其它输入设备) 初启跟踪事件通过调用 InputEngine.traceBegin () 方法。
  • 若当前输入法接受事件,它会创建跟踪对象并配置要求的数据通道 (若有的话)。
  • TraceInputArea collects the data for the trace object.
  • TraceInputArea 调用 InputEngine.traceEnd () method to finish the trace and passing the trace object back to input method.
  • The input method processes the data and discards the object when it is no longer needed.

The coordinate data is retrieved using the points () 函数。

In addition to coordinate based data, it is possible to attach an arbitrary data channel for each data point.

The data channels must be defined before the points are added. The data channels supported by the TraceInputArea are listed below:

  • "t" Collects time for each data point. The time is the number of milliseconds since 1970/01/01:

例如,要配置对象以收集每点的时间:

QVirtualKeyboardTrace *trace = new QVirtualKeyboardTrace(this);
trace->setChannels(QStringList() << "t");
					

可以访问收集数据使用 channelData () 函数:

QVariantList timeData = trace->channelData("t");
					

Trace objects are owned by their creator, which is the input method in normal case. This means the objects are constructed in the InputMethod.traceBegin () (QML) method.

根据定义,可以最早销毁跟踪对象在 InputMethod.traceEnd () (QML) method.

特性文档编制

canceled : bool

This property defines whether the Trace is canceled. The input data should not be processed from the Traces whose canceled 特性被设为 true。


channels : list < strings >

List of additional data channels in the Trace. This property must be initialized before the data is added.


final : bool

This property defines whether the Trace can accept more data. If the value is true ,不接受更多数据。


[since QtQuick.VirtualKeyboard 2.4] opacity : qreal

This property defines how opaque the Trace is.

较值产生更透明跟踪: 0.0 完全透明,而 1.0 完全不透明。

此特性很有用,为使旧跟踪更透明当添加新跟踪时。

This property was introduced in QtQuick.VirtualKeyboard 2.4.


traceId : int

Unique id of this Trace.


方法文档编制

int addPoint ( point point )

添加 point to the Trace.

方法返回点添加索引,或 -1 若点无法被添加 (即 final 为 True)。

注意: 返回索引被要求关联额外数据采用点使用 setChannelData () 函数。

var channelData ( string channel , int pos , int count )

返回数据从指定 channel . If no other parameters are given, the function returns all the data.

pos parameter is given, the function returns data starting at the position. The count 参数限制返回多少项。

另请参阅 setChannelData ().


var points ( int pos , int count )

Returns list of points. If no parameters are given, the function returns all the points.

pos parameter is given, the function returns points starting at the position. The count 参数限制返回多少点。

返回列表包含 point 类型。


void setChannelData ( int index , string channel , var data )

设置 data 为点在 index 按给定数据 channel .

若每数据点未调用此方法,将以空值填充通道数据。不管怎样,无法在任意索引处添加数据 (即:它必须与点数据同步添加)。

另请参阅 channelData ().


[since QtQuick.VirtualKeyboard.Styles 6.1] void startHideTimer ( int delayMs )

Starts a timer to set opacity to zero after delayMs . If called again within delayMs , the timer is restarted.

With this function the input method can hide the trace from screen before destroying the trace object, for example, to indicate that the trace has been processed.

This method was introduced in QtQuick.VirtualKeyboard.Styles 6.1.