Trace is a data model for touch input data. More...
Header: | #include <QVirtualKeyboardTrace> |
CMake: | find_package(Qt6 COMPONENTS VirtualKeyboard REQUIRED) target_link_libraries(mytarget PRIVATE Qt6::VirtualKeyboard) |
qmake: | QT += virtualkeyboard |
Since: | QtQuick.VirtualKeyboard 2.0 |
Instantiated By: | Trace |
Inherits: | QObject |
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 |
qreal | opacity() 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 | setFinal(bool final) |
void | setOpacity(qreal opacity) |
void | setTraceId(int id) |
void | startHideTimer(int delayMs) |
int | traceId() const |
void | canceledChanged(bool isCanceled) |
void | channelsChanged() |
void | finalChanged(bool isFinal) |
void | lengthChanged(int length) |
void | opacityChanged(qreal opacity) |
void | traceIdChanged(int traceId) |
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() 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:
QVirtualKeyboardTrace *trace = new QVirtualKeyboardTrace(this); trace->setChannels(QStringList() << "t");
The collected data can be accessed using the channelData() function:
QVariantList timeData = trace->channelData("t");
QVirtualKeyboardTrace 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.
defines whether the QVirtualKeyboardTrace is canceled.
The input data should not be processed from the Traces whose canceled
property set to true.
Access functions:
bool | isCanceled() const |
void | setCanceled(bool canceled) |
Notifier signal:
void | canceledChanged(bool isCanceled) |
list of data channels in the QQTrace.
This property must be initialized before the data is added.
Access functions:
QStringList | channels() const |
void | setChannels(const QStringList &channels) |
Notifier signal:
void | channelsChanged() |
defines whether the QVirtualKeyboardTrace can accept more data. If the value is true
, no more data is accepted.
Access functions:
bool | isFinal() const |
void | setFinal(bool final) |
Notifier signal:
void | finalChanged(bool isFinal) |
[read-only]
length : const int
This property holds the number of of points in the QVirtualKeyboardTrace.
Access functions:
int | length() const |
Notifier signal:
void | lengthChanged(int length) |
This property defines how opaque the QVirtualKeyboardTrace 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.
Access functions:
qreal | opacity() const |
void | setOpacity(qreal opacity) |
Notifier signal:
void | opacityChanged(qreal opacity) |
unique id of this QVirtualKeyboardTrace.
Access functions:
int | traceId() const |
void | setTraceId(int id) |
Notifier signal:
void | traceIdChanged(int traceId) |
[invokable]
int QVirtualKeyboardTrace::addPoint(const QPointF &point)
Adds a point to the QVirtualKeyboardTrace.
The method returns index of the point added, or -1 if the points cannot be added (i.e. the final is true).
Note: The returned index is required to associate additional data with the point using the setChannelData() method.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
QVariantList QVirtualKeyboardTrace::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.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also setChannelData().
[invokable]
QVariantList QVirtualKeyboardTrace::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.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
[invokable]
void QVirtualKeyboardTrace::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.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
See also channelData().
[invokable, since QtQuick.VirtualKeyboard.Styles 6.1]
void QVirtualKeyboardTrace::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.
Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.
This function was introduced in QtQuick.VirtualKeyboard.Styles 6.1.
© The Qt Company Ltd
Licensed under the GNU Free Documentation License, Version 1.3.
https://doc.qt.io/qt-6.2/qvirtualkeyboardtrace.html