summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qevent.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/kernel/qevent.cpp')
-rw-r--r--src/gui/kernel/qevent.cpp134
1 files changed, 98 insertions, 36 deletions
diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp
index 4fc3643d6..bc3633c5e 100644
--- a/src/gui/kernel/qevent.cpp
+++ b/src/gui/kernel/qevent.cpp
@@ -119,7 +119,7 @@ QInputEvent::~QInputEvent()
will not be propagated further up the parent widget chain.
The state of the keyboard modifier keys can be found by calling the
- \l{QInputEvent::modifiers()}{modifiers()} function, inhertied from
+ \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
QInputEvent.
The functions pos(), x(), and y() give the cursor position
@@ -675,8 +675,9 @@ QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
The QWidget::setEnable() function can be used to enable or disable
mouse and keyboard events for a widget.
- The event handlers QWidget::keyPressEvent() and
- QWidget::keyReleaseEvent() receive key events.
+ The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
+ QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
+ receive key events.
\sa QFocusEvent, QWidget::grabKeyboard()
*/
@@ -992,8 +993,9 @@ bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
The reason for a particular focus event is returned by reason()
in the appropriate event handler.
- The event handlers QWidget::focusInEvent() and
- QWidget::focusOutEvent() receive focus events.
+ The event handlers QWidget::focusInEvent(),
+ QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
+ QGraphicsItem::focusOutEvent() receive focus events.
\sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
*/
@@ -1611,12 +1613,14 @@ Qt::ButtonState QContextMenuEvent::state() const
string is controlled by the widget only). The AttributeType enum
describes the different attributes that can be set.
- A class implementing QWidget::inputMethodEvent() should at least
- understand and honor the \l TextFormat and \l Cursor attributes.
+ A class implementing QWidget::inputMethodEvent() or
+ QGraphicsItem::inputMethodEvent() should at least understand and
+ honor the \l TextFormat and \l Cursor attributes.
Since input methods need to be able to query certain properties
- from the widget, the widget must also implement
- QWidget::inputMethodQuery().
+ from the widget or graphics item, subclasses must also implement
+ QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
+ respectively.
When receiving an input method event, the text widget has to performs the
following steps:
@@ -3531,21 +3535,23 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
#endif
/*! \class QTouchEvent
- \brief The QTouchEvent class contains parameters that describe a touch event
-.
+ \brief The QTouchEvent class contains parameters that describe a touch event.
\since 4.6
\ingroup events
Touch events occur when pressing, releasing, or moving one or more
touch points on a touch device (such as a touch-screen or
- track-pad), and if the widget has the Qt::WA_AcceptTouchEvents
- attribute.
+ track-pad). To receive touch events, widgets have to have the
+ Qt::WA_AcceptTouchEvents attribute set and graphics items need to have
+ the \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents}
+ attribute set to true.
All touch events are of type QEvent::TouchBegin,
QEvent::TouchUpdate, or QEvent::TouchEnd. The touchPoints()
function returns a list of all touch points contained in the event.
- Information about each touch point can be retreived using the
- QTouchEvent::TouchPoint class.
+ Information about each touch point can be retrieved using the
+ QTouchEvent::TouchPoint class. The Qt::TouchPointState enum
+ describes the different states that a touch point may have.
Similar to QMouseEvent, Qt automatically grabs each touch point on
the first press inside a widget; the widget will receive all
@@ -3563,10 +3569,11 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
then mouse events are simulated from the state of the first touch
point.
- The Qt::TouchPointState enum describes the different states that a
- touch point may have.
+ Reimplement QWidget::event() for widgets and QGraphicsItem::sceneEvent()
+ for items in a graphics view to receive touch events.
- QTouchEvent::TouchPoint Qt::TouchPointState Qt::WA_AcceptTouchEvents
+ \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
+ QGraphicsItem::acceptTouchEvents()
*/
/*! \enum Qt::TouchPointState
@@ -3584,13 +3591,7 @@ QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
\omitvalue TouchPointPrimary
*/
-/*! \class QTouchEvent::TouchPoint
- \brief The QTouchEvent::TouchPoint class provide information about a touch point in a QTouchEvent.
- \since 4.6
-*/
-
/*! \enum QTouchEvent::DeviceType
- \since 4.6
This enum represents the type of device that generated a QTouchEvent.
@@ -3669,6 +3670,11 @@ QTouchEvent::~QTouchEvent()
Sets the list of touch points for this event.
*/
+/*! \class QTouchEvent::TouchPoint
+ \brief The QTouchEvent::TouchPoint class provides information about a touch point in a QTouchEvent.
+ \since 4.6
+*/
+
/*! \internal
Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
@@ -3728,7 +3734,9 @@ bool QTouchEvent::TouchPoint::isPrimary() const
/*!
Returns the position of this touch point, relative to the widget
- or item that received the event.
+ or QGraphicsItem that received the event.
+
+ \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
*/
QPointF QTouchEvent::TouchPoint::pos() const
{
@@ -3737,6 +3745,13 @@ QPointF QTouchEvent::TouchPoint::pos() const
/*!
Returns the scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa startScenePos(), lastScenePos(), pos()
*/
QPointF QTouchEvent::TouchPoint::scenePos() const
{
@@ -3745,6 +3760,8 @@ QPointF QTouchEvent::TouchPoint::scenePos() const
/*!
Returns the screen position of this touch point.
+
+ \sa startScreenPos(), lastScreenPos(), pos()
*/
QPointF QTouchEvent::TouchPoint::screenPos() const
{
@@ -3752,8 +3769,12 @@ QPointF QTouchEvent::TouchPoint::screenPos() const
}
/*!
- Returns the position of this touch point. The coordinates are normalized to size of the touch
- device, i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+ Returns the normalized position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa startNormalizedPos(), lastNormalizedPos(), pos()
*/
QPointF QTouchEvent::TouchPoint::normalizedPos() const
{
@@ -3762,7 +3783,9 @@ QPointF QTouchEvent::TouchPoint::normalizedPos() const
/*!
Returns the starting position of this touch point, relative to the
- widget that received the event.
+ widget or QGraphicsItem that received the event.
+
+ \sa pos(), lastPos()
*/
QPointF QTouchEvent::TouchPoint::startPos() const
{
@@ -3771,6 +3794,13 @@ QPointF QTouchEvent::TouchPoint::startPos() const
/*!
Returns the starting scene position of this touch point.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), lastScenePos()
*/
QPointF QTouchEvent::TouchPoint::startScenePos() const
{
@@ -3779,6 +3809,8 @@ QPointF QTouchEvent::TouchPoint::startScenePos() const
/*!
Returns the starting screen position of this touch point.
+
+ \sa screenPos(), lastScreenPos()
*/
QPointF QTouchEvent::TouchPoint::startScreenPos() const
{
@@ -3786,8 +3818,12 @@ QPointF QTouchEvent::TouchPoint::startScreenPos() const
}
/*!
- Returns the starting position of this touch point. The coordinates are normalized to size of
- the touch device, i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+ Returns the normalized starting position of this touch point.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), lastNormalizedPos()
*/
QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
{
@@ -3796,7 +3832,9 @@ QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
/*!
Returns the position of this touch point from the previous touch
- event, relative to the widget that received the event.
+ event, relative to the widget or QGraphicsItem that received the event.
+
+ \sa pos(), startPos()
*/
QPointF QTouchEvent::TouchPoint::lastPos() const
{
@@ -3806,6 +3844,13 @@ QPointF QTouchEvent::TouchPoint::lastPos() const
/*!
Returns the scene position of this touch point from the previous
touch event.
+
+ The scene position is the position in QGraphicsScene coordinates
+ if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
+ reimplementation, and identical to the screen position for
+ widgets.
+
+ \sa scenePos(), startScenePos()
*/
QPointF QTouchEvent::TouchPoint::lastScenePos() const
{
@@ -3815,6 +3860,8 @@ QPointF QTouchEvent::TouchPoint::lastScenePos() const
/*!
Returns the screen position of this touch point from the previous
touch event.
+
+ \sa screenPos(), startScreenPos()
*/
QPointF QTouchEvent::TouchPoint::lastScreenPos() const
{
@@ -3822,9 +3869,13 @@ QPointF QTouchEvent::TouchPoint::lastScreenPos() const
}
/*!
- Returns the position of this touch point from the previous touch event. The coordinates are
- normalized to size of the touch device, i.e. (0,0) is the top-left corner and (1,1) is the
- bottom-right corner.
+ Returns the normalized position of this touch point from the
+ previous touch event.
+
+ The coordinates are normalized to the size of the touch device,
+ i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
+
+ \sa normalizedPos(), startNormalizedPos()
*/
QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
{
@@ -3832,8 +3883,11 @@ QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
}
/*!
- Returns the rect for this touch point. The rect is centered around the point returned by pos().
- Note this function returns an empty rect if the device does not report touch point sizes.
+ Returns the rect for this touch point, relative to the widget
+ or QGraphicsItem that received the event. The rect is centered
+ around the point returned by pos().
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
*/
QRectF QTouchEvent::TouchPoint::rect() const
{
@@ -3842,6 +3896,10 @@ QRectF QTouchEvent::TouchPoint::rect() const
/*!
Returns the rect for this touch point in scene coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa scenePos(), rect()
*/
QRectF QTouchEvent::TouchPoint::sceneRect() const
{
@@ -3850,6 +3908,10 @@ QRectF QTouchEvent::TouchPoint::sceneRect() const
/*!
Returns the rect for this touch point in screen coordinates.
+
+ \note This function returns an empty rect if the device does not report touch point sizes.
+
+ \sa screenPos(), rect()
*/
QRectF QTouchEvent::TouchPoint::screenRect() const
{