Trace is a data model for touch input data. 更多...
导入语句: | import QtQuick.VirtualKeyboard 2.2 |
Since: | QtQuick.VirtualKeyboard 2.0 |
实例化: | QVirtualKeyboardTrace |
Trace provides the data model for coordinate data and other optional data associated with a single stroke.
A typical use case for the trace object is as follows:
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:
For example, to configure the object to collect the times for each point:
QVirtualKeyboardTrace *trace = new QVirtualKeyboardTrace(this); trace->setChannels(QStringList() << "t");
The collected data can be accessed using the 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.
By definition, the trace object can be destroyed at earliest in the 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
property set to 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
, no more data is accepted.
[since QtQuick.VirtualKeyboard 2.4] opacity : qreal |
This property defines how opaque the Trace is.
A lower value results in a more transparent trace:
0.0
is fully transparent, and
1.0
is fully opaque.
This property is useful for making older traces more transparent as new ones are added.
This property was introduced in QtQuick.VirtualKeyboard 2.4.
traceId : int |
Unique id of this Trace.
int addPoint ( point point ) |
Adds a point to the Trace.
The method returns index of the point added, or -1 if the points cannot be added (i.e. the final 为 True)。
注意: The returned index is required to associate additional data with the point using the setChannelData() 函数。
var channelData ( string channel , int pos , int count ) |
Returns data from the specified 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 parameter limits how many items are returned.
另请参阅 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 parameter limits how many points are returned.
The returned list contains
point
类型。
void setChannelData ( int index , string channel , var data ) |
设置 data for the point at index in the given data channel .
If this method is not called for each data point, the channel data will be padded with empty values. However, the data cannot be added at arbitrary index, i.e., it must be added in synchronously with the point data.
另请参阅 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.