Trace QML Type | Qt Virtual Keyboard 5.9

Qt 5.9 | Qt Virtual Keyboard | QML Types | Trace QML Type

Qt 5.9.3 Reference Documentation

# Trace QML Type

Trace is a data model for touch input data. More...

Import Statement: | import QtQuick.VirtualKeyboard 2.2
Since: | QtQuick.VirtualKeyboard 2.0

- List of all members, including inherited members

## Properties

- channels : list<strings>
- isCanceled : bool
- isFinal : bool
- length : int
- traceId : int

## Methods

- 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)

## Detailed Description

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:

- TraceInputArea or other input device initiates the trace event by calling InputEngine.traceBegin() method.
- If the current input method accepts the event it creates a trace object and configures the required data channels (if any).
- TraceInputArea collects the data for the trace object.
- TraceInputArea calls the 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() function.

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:

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

The collected data can be accessed using the channelData() function:

      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.

## Property Documentation

channels : list<strings>

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

isCanceled : bool

This property defines whether the Trace is canceled. The input data should not be processed from the Traces whose isCanceled property set to true.

isFinal : bool

This property defines whether the Trace can accept more data. If the value is true, no more data is accepted.

length : int

The number of points in the Trace.

traceId : int

Unique id of this Trace.

## Method Documentation

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 isFinal is true).

Note: The returned index is required to associate additional data with the point using the setChannelData() function.

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.

If the pos parameter is given, the function returns data starting at the position. The count parameter limits how many items are returned.

var points(int pos, int count)

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

If the 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` types.

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

Sets 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.