Qt 4.8
Public Functions | Private Functions | Properties | Friends | List of all members
QTest::QTouchEventSequence Class Reference

The QTouchEventSequence class is used to simulate a sequence of touch events. More...

#include <qtesttouch.h>

Public Functions

QTouchEventSequencemove (int touchId, const QPoint &pt, QWidget *widget=0)
 Adds a move event for touchpoint touchId at position pt to this sequence and returns a reference to this QTouchEventSequence. More...
 
QTouchEventSequencepress (int touchId, const QPoint &pt, QWidget *widget=0)
 Adds a press event for touchpoint touchId at position pt to this sequence and returns a reference to this QTouchEventSequence. More...
 
QTouchEventSequencerelease (int touchId, const QPoint &pt, QWidget *widget=0)
 Adds a release event for touchpoint touchId at position pt to this sequence and returns a reference to this QTouchEventSequence. More...
 
QTouchEventSequencestationary (int touchId)
 Adds a stationary event for touchpoint touchId to this sequence and returns a reference to this QTouchEventSequence. More...
 
 ~QTouchEventSequence ()
 Commits this sequence of touch events and frees allocated resources. More...
 

Private Functions

void commit ()
 
QPoint mapToScreen (QWidget *widget, const QPoint &pt)
 
void operator= (const QTouchEventSequence &)
 
QTouchEvent::TouchPointpoint (int touchId)
 
 QTouchEventSequence (QWidget *widget, QTouchEvent::DeviceType aDeviceType)
 
 QTouchEventSequence (const QTouchEventSequence &v)
 

Properties

QTouchEvent::DeviceType deviceType
 
QMap< int, QTouchEvent::TouchPointpoints
 
QWidgettargetWidget
 

Friends

QTouchEventSequence touchEvent (QWidget *, QTouchEvent::DeviceType)
 

Detailed Description

The QTouchEventSequence class is used to simulate a sequence of touch events.

Attention
Module: QtTest
Since
4.6

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

Example:

.press(0, QPoint(10, 10));
.press(1, QPoint(40, 10));
.move(0, QPoint(12, 12))
.move(1, QPoint(45, 5));
.release(0)
.release(1);

Definition at line 72 of file qtesttouch.h.

Constructors and Destructors

◆ ~QTouchEventSequence()

QTest::QTouchEventSequence::~QTouchEventSequence ( )
inline

Commits this sequence of touch events and frees allocated resources.

Definition at line 75 of file qtesttouch.h.

76  {
77  commit();
78  points.clear();
79  }
QMap< int, QTouchEvent::TouchPoint > points
Definition: qtesttouch.h:134
void clear()
Removes all items from the map.
Definition: qmap.h:444

◆ QTouchEventSequence() [1/2]

QTest::QTouchEventSequence::QTouchEventSequence ( QWidget widget,
QTouchEvent::DeviceType  aDeviceType 
)
inlineprivate

Definition at line 109 of file qtesttouch.h.

Referenced by QTest::touchEvent().

110  : targetWidget(widget), deviceType(aDeviceType)
111  {
112  }
QTouchEvent::DeviceType deviceType
Definition: qtesttouch.h:136

◆ QTouchEventSequence() [2/2]

QTest::QTouchEventSequence::QTouchEventSequence ( const QTouchEventSequence v)
private

Functions

◆ commit()

void QTest::QTouchEventSequence::commit ( )
inlineprivate

Definition at line 128 of file qtesttouch.h.

Referenced by ~QTouchEventSequence().

129  {
131  targetWidget = 0;
132  }
QTouchEvent::DeviceType deviceType
Definition: qtesttouch.h:136
QList< T > values() const
Returns a list containing all the values in the map, in ascending order of their keys.
Definition: qmap.h:863
QMap< int, QTouchEvent::TouchPoint > points
Definition: qtesttouch.h:134
Q_GUI_EXPORT void qt_translateRawTouchEvent(QWidget *window, QTouchEvent::DeviceType deviceType, const QList< QTouchEvent::TouchPoint > &touchPoints)

◆ mapToScreen()

QPoint QTest::QTouchEventSequence::mapToScreen ( QWidget widget,
const QPoint pt 
)
inlineprivate

Definition at line 122 of file qtesttouch.h.

Referenced by move(), press(), and release().

123  {
124  if (widget)
125  return widget->mapToGlobal(pt);
126  return targetWidget ? targetWidget->mapToGlobal(pt) : pt;
127  }
QPoint mapToGlobal(const QPoint &) const
Translates the widget coordinate pos to global screen coordinates.

◆ move()

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

Adds a move event for touchpoint touchId at position pt to this sequence and returns a reference to this QTouchEventSequence.

The position pt is interpreted as relative to widget. If 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.

Definition at line 87 of file qtesttouch.h.

88  {
89  QTouchEvent::TouchPoint &p = point(touchId);
90  p.setScreenPos(mapToScreen(widget, pt));
92  return *this;
93  }
void setScreenPos(const QPointF &screenPos)
Definition: qevent.cpp:4695
QTouchEvent::TouchPoint & point(int touchId)
Definition: qtesttouch.h:116
QPoint mapToScreen(QWidget *widget, const QPoint &pt)
Definition: qtesttouch.h:122
void setState(Qt::TouchPointStates state)
Definition: qevent.cpp:4671
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744

◆ operator=()

void QTest::QTouchEventSequence::operator= ( const QTouchEventSequence )
private

Referenced by QTouchEventSequence().

◆ point()

QTouchEvent::TouchPoint& QTest::QTouchEventSequence::point ( int  touchId)
inlineprivate

Definition at line 116 of file qtesttouch.h.

Referenced by move(), press(), release(), and stationary().

117  {
118  if (!points.contains(touchId))
119  points[touchId] = QTouchEvent::TouchPoint(touchId);
120  return points[touchId];
121  }
bool contains(const Key &key) const
Returns true if the map contains an item with key key; otherwise returns false.
Definition: qmap.h:553
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744
QMap< int, QTouchEvent::TouchPoint > points
Definition: qtesttouch.h:134

◆ press()

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

Adds a press event for touchpoint touchId at position pt to this sequence and returns a reference to this QTouchEventSequence.

The position pt is interpreted as relative to widget. If 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.

Definition at line 80 of file qtesttouch.h.

81  {
82  QTouchEvent::TouchPoint &p = point(touchId);
83  p.setScreenPos(mapToScreen(widget, pt));
85  return *this;
86  }
void setScreenPos(const QPointF &screenPos)
Definition: qevent.cpp:4695
QTouchEvent::TouchPoint & point(int touchId)
Definition: qtesttouch.h:116
QPoint mapToScreen(QWidget *widget, const QPoint &pt)
Definition: qtesttouch.h:122
void setState(Qt::TouchPointStates state)
Definition: qevent.cpp:4671
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744

◆ release()

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

Adds a release event for touchpoint touchId at position pt to this sequence and returns a reference to this QTouchEventSequence.

The position pt is interpreted as relative to widget. If 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.

Definition at line 94 of file qtesttouch.h.

95  {
96  QTouchEvent::TouchPoint &p = point(touchId);
97  p.setScreenPos(mapToScreen(widget, pt));
99  return *this;
100  }
void setScreenPos(const QPointF &screenPos)
Definition: qevent.cpp:4695
QTouchEvent::TouchPoint & point(int touchId)
Definition: qtesttouch.h:116
QPoint mapToScreen(QWidget *widget, const QPoint &pt)
Definition: qtesttouch.h:122
void setState(Qt::TouchPointStates state)
Definition: qevent.cpp:4671
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744

◆ stationary()

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

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.

Definition at line 101 of file qtesttouch.h.

102  {
103  QTouchEvent::TouchPoint &p = point(touchId);
105  return *this;
106  }
QTouchEvent::TouchPoint & point(int touchId)
Definition: qtesttouch.h:116
void setState(Qt::TouchPointStates state)
Definition: qevent.cpp:4671
The TouchPoint class provides information about a touch point in a QTouchEvent.
Definition: qevent.h:744

Friends and Related Functions

◆ touchEvent

QTouchEventSequence touchEvent ( QWidget widget = 0,
QTouchEvent::DeviceType  deviceType = QTouchEvent::TouchScreen 
)
friend

Definition at line 141 of file qtesttouch.h.

143  {
144  return QTouchEventSequence(widget, deviceType);
145  }
QTouchEvent::DeviceType deviceType
Definition: qtesttouch.h:136
QTouchEventSequence(QWidget *widget, QTouchEvent::DeviceType aDeviceType)
Definition: qtesttouch.h:109

Properties

◆ deviceType

QTouchEvent::DeviceType QTest::QTouchEventSequence::deviceType
private

Definition at line 136 of file qtesttouch.h.

Referenced by commit(), and QTest::touchEvent().

◆ points

QMap<int, QTouchEvent::TouchPoint> QTest::QTouchEventSequence::points
private

Definition at line 134 of file qtesttouch.h.

Referenced by commit(), point(), and ~QTouchEventSequence().

◆ targetWidget

QWidget* QTest::QTouchEventSequence::targetWidget
private

Definition at line 135 of file qtesttouch.h.

Referenced by commit(), and mapToScreen().


The documentation for this class was generated from the following files: