Trace Class
(QtVirtualKeyboard::Trace)Trace is a data model for touch input data. More...
Header: | #include <Trace> |
Since: | QtQuick.VirtualKeyboard 2.0 |
Instantiated By: | Trace |
Inherits: | QObject |
Properties
|
- 1 property inherited from QObject
Public Functions
int | addPoint(const QPointF &point) |
QVariantList | channelData(const QString &channel, int pos = 0, int count = -1) const |
QStringList | channels() const |
bool | isCanceled() const |
bool | isFinal() const |
int | length() const |
QVariantList | points(int pos = 0, int count = -1) const |
void | setCanceled(bool canceled) |
void | setChannelData(const QString &channel, int index, const QVariant &data) |
void | setChannels(const QStringList &channels) |
void | setTraceId(int id) |
int | traceId() const |
- 31 public functions inherited from QObject
Signals
void | canceledChanged(bool isCanceled) |
void | channelsChanged() |
void | finalChanged(bool isFinal) |
void | lengthChanged(int length) |
void | traceIdChanged(int traceId) |
- 2 signals inherited from QObject
Additional Inherited Members
- 1 public slot inherited from QObject
- 1 public variable inherited from QObject
- 10 static public members inherited from QObject
- 9 protected functions inherited from QObject
- 2 protected variables inherited from QObject
Detailed Description
Trace is a data model for touch input data.
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 AbstractInputMethod::traceBegin() (C++) or InputMethod.traceBegin() (QML) method.
By definition, the trace object can be destroyed at earliest in the AbstractInputMethod::traceEnd() (C++) or InputMethod.traceEnd() (QML) method.
Property Documentation
channels : QStringList
This property holds list of data channels in the Trace.
This property must be initialized before the data is added.
Access functions:
QStringList | channels() const |
void | setChannels(const QStringList &channels) |
Notifier signal:
void | channelsChanged() |
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.
Access functions:
bool | isCanceled() const |
void | setCanceled(bool canceled) |
Notifier signal:
void | canceledChanged(bool isCanceled) |
isFinal : const bool
This property defines whether the Trace can accept more data. If the value is true, no more data is accepted.
Access functions:
bool | isFinal() const |
Notifier signal:
void | finalChanged(bool isFinal) |
length : const int
This property holds the number of of points in the Trace.
Access functions:
int | length() const |
Notifier signal:
void | lengthChanged(int length) |
traceId : int
This property holds unique id of this Trace.
Access functions:
int | traceId() const |
void | setTraceId(int id) |
Notifier signal:
void | traceIdChanged(int traceId) |
Member Function Documentation
int Trace::addPoint(const QPointF &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() method.
QVariantList Trace::channelData(const QString &channel, int pos = 0, int count = -1) const
Returns data from the specified channel. If no other parameters are given, the method returns all the data.
If the pos parameter is given, the method returns data starting at the position. The count parameter limits how many items are returned.
See also setChannelData().
QVariantList Trace::points(int pos = 0, int count = -1) const
Returns list of points. If no parameters are given, the method returns all the data.
If the pos parameter is given, the method returns points starting at the position. The count parameter limits how many points are returned.
The returned list contains QPointF types.
void Trace::setChannelData(const QString &channel, int index, const QVariant &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.
See also channelData().