QVirtualKeyboardTrace Class

Trace is a data model for touch input data. 更多...

头: #include <QVirtualKeyboardTrace>
qmake: QT += virtualkeyboard
Since: QtQuick.VirtualKeyboard 2.0
实例化: Trace
继承: QObject

This class was introduced in QtQuick.VirtualKeyboard 2.0.

特性

公共函数

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

  • TraceInputArea or other input device initiates the trace event by calling InputEngine.traceBegin() 方法。
  • 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 调用 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:

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

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.

特性文档编制

canceled : bool

defines whether the QVirtualKeyboardTrace is canceled.

The input data should not be processed from the Traces whose canceled property set to true.

访问函数:

bool isCanceled () const
void setCanceled (bool canceled )

通知程序信号:

void canceledChanged (bool isCanceled )

channels : QStringList

list of data channels in the QQTrace.

This property must be initialized before the data is added.

访问函数:

QStringList channels () const
void setChannels (const QStringList & channels )

通知程序信号:

void channelsChanged ()

final : bool

defines whether the QVirtualKeyboardTrace can accept more data. If the value is true , no more data is accepted.

访问函数:

bool isFinal () const
void setFinal (bool final )

通知程序信号:

void finalChanged (bool isFinal )

length : const int

This property holds the number of of points in the QVirtualKeyboardTrace .

访问函数:

int length () const

通知程序信号:

void lengthChanged (int length )

opacity : qreal

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.

访问函数:

qreal opacity () const
void setOpacity (qreal opacity )

通知程序信号:

void opacityChanged (qreal opacity )

traceId : int

unique id of this QVirtualKeyboardTrace .

访问函数:

int traceId () const
void setTraceId (int id )

通知程序信号:

void traceIdChanged (int traceId )

成员函数文档编制

int QVirtualKeyboardTrace:: addPoint (const QPointF & point )

Adds a point QVirtualKeyboardTrace .

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 () 方法。

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_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.

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

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

另请参阅 setChannelData ().

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.

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 类型。

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

void QVirtualKeyboardTrace:: setChannelData (const QString & channel , int index , const QVariant & 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.

注意: 此函数可以被援引,通过元对象系统和从 QML。见 Q_INVOKABLE .

另请参阅 channelData ().