QTouchEventSequence 类

class QTest ::QTouchEventSequence

QTouchEventSequence 类用于模拟一系列触摸事件。 更多...

头: #include <QTouchEventSequence>
qmake: QT += testlib
Since: Qt 4.6

该类在 Qt 4.6 引入。

公共函数

~QTouchEventSequence ()
void commit (bool processEvents = true)
QTest::QTouchEventSequence & move (int touchId , const QPoint & pt , QWindow * window = nullptr)
QTest::QTouchEventSequence & move (int touchId , const QPoint & pt , QWidget * widget = nullptr)
QTest::QTouchEventSequence & press (int touchId , const QPoint & pt , QWindow * window = nullptr)
QTest::QTouchEventSequence & press (int touchId , const QPoint & pt , QWidget * widget = nullptr)
QTest::QTouchEventSequence & release (int touchId , const QPoint & pt , QWindow * window = nullptr)
QTest::QTouchEventSequence & release (int touchId , const QPoint & pt , QWidget * widget = nullptr)
QTest::QTouchEventSequence & stationary (int touchId )

详细描述

To simulate a sequence of touch events on a specific device for a window or widget, call QTest::touchEvent to create a QTouchEventSequence instance. Add touch events to the sequence by calling press (), move (), release () 和 stationary (), and let the instance run out of scope to commit the sequence to the event system.

范例:

QTouchDevice *dev = QTest::createTouchDevice();
QWidget widget;
QTest::touchEvent(&widget, dev)
    .press(0, QPoint(10, 10));
QTest::touchEvent(&widget, dev)
    .stationary(0)
    .press(1, QPoint(40, 10));
QTest::touchEvent(&widget, dev)
    .move(0, QPoint(12, 12))
    .move(1, QPoint(45, 5));
QTest::touchEvent(&widget, dev)
    .release(0, QPoint(12, 12))
    .release(1, QPoint(45, 5));
					

成员函数文档编制

QTouchEventSequence:: ~QTouchEventSequence ()

Commits this sequence of touch events, unless autoCommit was disabled, and frees allocated resources.

void QTouchEventSequence:: commit ( bool processEvents = true)

Commits this sequence of touch events to the event system. Normally there is no need to call this function because it is called from the destructor. However, if autoCommit is disabled, the events only get committed upon explicitly calling this function.

In special cases tests may want to disable the processing of the events. This can be achieved by setting processEvents to false. This results in merely queuing the events, the event loop will not be forced to process them.

QTest::QTouchEventSequence &QTouchEventSequence:: move ( int touchId , const QPoint & pt , QWindow * window = nullptr)

Adds a move event for touchpoint touchId 在位置 pt to this sequence and returns a reference to this QTouchEventSequence .

The position pt is interpreted as relative to window 。若 window is the null pointer, then pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence .

Simulates that the user moved the finger identified by touchId .

该函数在 Qt 5.0 引入。

QTest::QTouchEventSequence &QTouchEventSequence:: move ( int touchId , const QPoint & pt , QWidget * widget = nullptr)

Adds a move event for touchpoint touchId 在位置 pt to this sequence and returns a reference to this QTouchEventSequence .

The position pt is interpreted as relative to widget 。若 widget is the null pointer, then pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence .

Simulates that the user moved the finger identified by touchId .

QTest::QTouchEventSequence &QTouchEventSequence:: press ( int touchId , const QPoint & pt , QWindow * window = nullptr)

Adds a press event for touchpoint touchId 在位置 pt to this sequence and returns a reference to this QTouchEventSequence .

The position pt is interpreted as relative to window 。若 window is the null pointer, then pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence .

Simulates that the user pressed the touch screen or pad with the finger identified by touchId .

该函数在 Qt 5.0 引入。

QTest::QTouchEventSequence &QTouchEventSequence:: press ( int touchId , const QPoint & pt , QWidget * widget = nullptr)

Adds a press event for touchpoint touchId 在位置 pt to this sequence and returns a reference to this QTouchEventSequence .

The position pt is interpreted as relative to widget 。若 widget is the null pointer, then pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence .

Simulates that the user pressed the touch screen or pad with the finger identified by touchId .

QTest::QTouchEventSequence &QTouchEventSequence:: release ( int touchId , const QPoint & pt , QWindow * window = nullptr)

Adds a release event for touchpoint touchId 在位置 pt to this sequence and returns a reference to this QTouchEventSequence .

The position pt is interpreted as relative to window 。若 window is the null pointer, then pt is interpreted as relative to the window provided when instantiating this QTouchEventSequence .

Simulates that the user lifted the finger identified by touchId .

该函数在 Qt 5.0 引入。

QTest::QTouchEventSequence &QTouchEventSequence:: release ( int touchId , const QPoint & pt , QWidget * widget = nullptr)

Adds a release event for touchpoint touchId 在位置 pt to this sequence and returns a reference to this QTouchEventSequence .

The position pt is interpreted as relative to widget 。若 widget is the null pointer, then pt is interpreted as relative to the widget provided when instantiating this QTouchEventSequence .

Simulates that the user lifted the finger identified by touchId .

QTest::QTouchEventSequence &QTouchEventSequence:: stationary ( int touchId )

Adds a stationary event for touchpoint touchId to this sequence and returns a reference to this QTouchEventSequence .

Simulates that the user did not move the finger identified by touchId .