1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
44 #include "private/qguiapplication_p.h"
45 #include "qpa/qplatformintegration.h"
46 #include "qpa/qplatformdrag.h"
47 #include "private/qevent_p.h"
48 #include "private/qkeysequence_p.h"
50 #include "qmimedata.h"
51 #include "private/qdnd_p.h"
63 \brief The QInputEvent class is the base class for events that
70 QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
71 : QEvent(type), modState(modifiers), ts(0)
77 QInputEvent::~QInputEvent()
82 \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
84 Returns the keyboard modifier flags that existed immediately
85 before the event occurred.
87 \sa QApplication::keyboardModifiers()
90 /*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
94 Sets the keyboard modifiers flags for this event.
101 \brief The QMouseEvent class contains parameters that describe a mouse event.
103 Mouse events occur when a mouse button is pressed or released
104 inside a widget, or when the mouse cursor is moved.
106 Mouse move events will occur only when a mouse button is pressed
107 down, unless mouse tracking has been enabled with
108 QWidget::setMouseTracking().
110 Qt automatically grabs the mouse when a mouse button is pressed
111 inside a widget; the widget will continue to receive mouse events
112 until the last mouse button is released.
114 A mouse event contains a special accept flag that indicates
115 whether the receiver wants the event. You should call ignore() if
116 the mouse event is not handled by your widget. A mouse event is
117 propagated up the parent widget chain until a widget accepts it
118 with accept(), or an event filter consumes it.
120 \note If a mouse event is propagated to a \l{QWidget}{widget} for
121 which Qt::WA_NoMousePropagation has been set, that mouse event
122 will not be propagated further up the parent widget chain.
124 The state of the keyboard modifier keys can be found by calling the
125 \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
128 The functions pos(), x(), and y() give the cursor position
129 relative to the widget that receives the mouse event. If you
130 move the widget as a result of the mouse event, use the global
131 position returned by globalPos() to avoid a shaking motion.
133 The QWidget::setEnabled() function can be used to enable or
134 disable mouse and keyboard events for a widget.
136 Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
137 QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
138 and QWidget::mouseMoveEvent() to receive mouse events in your own
141 \sa QWidget::setMouseTracking(), QWidget::grabMouse(),
146 Constructs a mouse event object.
148 The \a type parameter must be one of QEvent::MouseButtonPress,
149 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
150 or QEvent::MouseMove.
152 The \a localPos is the mouse cursor's position relative to the
153 receiving widget or item. The window position is set to the same value
155 The \a button that caused the event is given as a value from
156 the Qt::MouseButton enum. If the event \a type is
157 \l MouseMove, the appropriate button for this event is Qt::NoButton.
158 The mouse and keyboard states at the time of the event are specified by
159 \a buttons and \a modifiers.
161 The screenPos() is initialized to QCursor::pos(), which may not
162 be appropriate. Use the other constructor to specify the global
165 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
166 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
167 : QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
174 Constructs a mouse event object.
176 The \a type parameter must be QEvent::MouseButtonPress,
177 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
178 or QEvent::MouseMove.
180 The \a localPos is the mouse cursor's position relative to the
181 receiving widget or item. The cursor's position in screen coordinates is
182 specified by \a screenPos. The window position is set to the same value
183 as \a localPos. The \a button that caused the event is
184 given as a value from the \l Qt::MouseButton enum. If the event \a
185 type is \l MouseMove, the appropriate button for this event is
186 Qt::NoButton. \a buttons is the state of all buttons at the
187 time of the event, \a modifiers the state of all keyboard
191 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
192 Qt::MouseButton button, Qt::MouseButtons buttons,
193 Qt::KeyboardModifiers modifiers)
194 : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0)
198 Constructs a mouse event object.
200 The \a type parameter must be QEvent::MouseButtonPress,
201 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
202 or QEvent::MouseMove.
204 The \a pos is the mouse cursor's position relative to the
205 receiving widget. The cursor's position in global coordinates is
206 specified by \a globalPos. The \a button that caused the event is
207 given as a value from the \l Qt::MouseButton enum. If the event \a
208 type is \l MouseMove, the appropriate button for this event is
209 Qt::NoButton. \a buttons is the state of all buttons at the
210 time of the event, \a modifiers the state of all keyboard
214 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
215 Qt::MouseButton button, Qt::MouseButtons buttons,
216 Qt::KeyboardModifiers modifiers)
217 : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
223 QMouseEvent::~QMouseEvent()
229 \fn QPointF QMouseEvent::localPos() const
233 Returns the position of the mouse cursor as a QPointF, relative to the
234 widget or item that received the event.
236 If you move the widget as a result of the mouse event, use the
237 screen position returned by screenPos() to avoid a shaking
240 \sa x(), y(), windowPos(), screenPos()
244 \fn QPointF QMouseEvent::windowPos() const
248 Returns the position of the mouse cursor as a QPointF, relative to the
249 window that received the event.
251 If you move the widget as a result of the mouse event, use the
252 global position returned by globalPos() to avoid a shaking
255 \sa x(), y(), pos(), localPos(), screenPos()
259 \fn QPointF QMouseEvent::screenPos() const
263 Returns the position of the mouse cursor as a QPointF, relative to the
264 screen that received the event.
266 \sa x(), y(), pos(), localPos(), screenPos()
270 \fn const QPoint &QMouseEvent::pos() const
272 Returns the position of the mouse cursor, relative to the widget
273 that received the event.
275 If you move the widget as a result of the mouse event, use the
276 global position returned by globalPos() to avoid a shaking
279 \sa x(), y(), globalPos()
283 \fn const QPoint &QMouseEvent::globalPos() const
285 Returns the global position of the mouse cursor \e{at the time
286 of the event}. This is important on asynchronous window systems
287 like X11. Whenever you move your widgets around in response to
288 mouse events, globalPos() may differ a lot from the current
289 pointer position QCursor::pos(), and from
290 QWidget::mapToGlobal(pos()).
292 \sa globalX(), globalY()
296 \fn int QMouseEvent::x() const
298 Returns the x position of the mouse cursor, relative to the
299 widget that received the event.
305 \fn int QMouseEvent::y() const
307 Returns the y position of the mouse cursor, relative to the
308 widget that received the event.
314 \fn int QMouseEvent::globalX() const
316 Returns the global x position of the mouse cursor at the time of
319 \sa globalY(), globalPos()
323 \fn int QMouseEvent::globalY() const
325 Returns the global y position of the mouse cursor at the time of
328 \sa globalX(), globalPos()
332 \fn Qt::MouseButton QMouseEvent::button() const
334 Returns the button that caused the event.
336 Note that the returned value is always Qt::NoButton for mouse
339 \sa buttons(), Qt::MouseButton
343 \fn Qt::MouseButton QMouseEvent::buttons() const
345 Returns the button state when the event was generated. The button
346 state is a combination of Qt::LeftButton, Qt::RightButton,
347 Qt::MidButton using the OR operator. For mouse move events,
348 this is all buttons that are pressed down. For mouse press and
349 double click events this includes the button that caused the
350 event. For mouse release events this excludes the button that
353 \sa button(), Qt::MouseButton
360 \brief The QHoverEvent class contains parameters that describe a mouse event.
362 Mouse events occur when a mouse cursor is moved into, out of, or within a
363 widget, and if the widget has the Qt::WA_Hover attribute.
365 The function pos() gives the current cursor position, while oldPos() gives
366 the old mouse position.
368 There are a few similarities between the events QEvent::HoverEnter
369 and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
370 However, they are slightly different because we do an update() in the event
371 handler of HoverEnter and HoverLeave.
373 QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
374 consider a top-level window A containing a child B which in turn contains a
375 child C (all with mouse tracking enabled):
377 \image hoverevents.png
379 Now, if you move the cursor from the top to the bottom in the middle of A,
380 you will get the following QEvent::MouseMove events:
388 You will get the same events for QEvent::HoverMove, except that the event
389 always propagates to the top-level regardless whether the event is accepted
390 or not. It will only stop propagating with the Qt::WA_NoMousePropagation
393 In this case the events will occur in the following way:
397 \li A::HoverMove, B::HoverMove
398 \li A::HoverMove, B::HoverMove, C::HoverMove
404 \fn const QPoint &QHoverEvent::pos() const
406 Returns the position of the mouse cursor, relative to the widget
407 that received the event.
409 On QEvent::HoverLeave events, this position will always be
416 \fn const QPoint &QHoverEvent::oldPos() const
418 Returns the previous position of the mouse cursor, relative to the widget
419 that received the event. If there is no previous position, oldPos() will
420 return the same position as pos().
422 On QEvent::HoverEnter events, this position will always be
429 Constructs a hover event object.
431 The \a type parameter must be QEvent::HoverEnter,
432 QEvent::HoverLeave, or QEvent::HoverMove.
434 The \a pos is the current mouse cursor's position relative to the
435 receiving widget, while \a oldPos is the previous mouse cursor's
436 position relative to the receiving widget.
438 QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers)
439 : QInputEvent(type, modifiers), p(pos), op(oldPos)
446 QHoverEvent::~QHoverEvent()
453 \brief The QWheelEvent class contains parameters that describe a wheel event.
458 Wheel events are sent to the widget under the mouse cursor, but
459 if that widget does not handle the event they are sent to the
460 focus widget. Wheel events are generated for both mouse wheels
461 and trackpad scroll gestures. There are two ways to read the
462 wheel event delta: angleDelta() returns the delta in wheel
463 degrees. This value is always provided. pixelDelta() returns
464 the delta in screen pixels and is available on platforms that
465 have high-resolution trackpads, such as Mac OS X.
467 The functions pos() and globalPos() return the mouse cursor's
468 location at the time of the event.
470 A wheel event contains a special accept flag that indicates
471 whether the receiver wants the event. You should call ignore() if
472 you do not handle the wheel event; this ensures that it will be
473 sent to the parent widget.
475 The QWidget::setEnabled() function can be used to enable or
476 disable mouse and keyboard events for a widget.
478 The event handler QWidget::wheelEvent() receives wheel events.
480 \sa QMouseEvent, QWidget::grabMouse()
484 \fn Qt::MouseButtons QWheelEvent::buttons() const
486 Returns the mouse state when the event occurred.
490 \fn Qt::Orientation QWheelEvent::orientation() const
492 Returns the wheel's orientation.
497 Constructs a wheel event object.
499 Use the QPoint-based constructor instead.
501 The position, \a pos, is the location of the mouse cursor within
502 the widget. The globalPos() is initialized to QCursor::pos()
503 which is usually, but not always, correct.
504 Use the other constructor if you need to specify the global
507 The \a buttons describe the state of the mouse buttons at the time
508 of the event, \a delta contains the rotation distance,
509 \a modifiers holds the keyboard modifier flags at the time of the
510 event, and \a orient holds the wheel's orientation.
512 \sa pos(), pixelDelta(), angleDelta(), state()
514 #ifndef QT_NO_WHEELEVENT
515 QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
516 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
517 Qt::Orientation orient)
518 : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons)
526 QWheelEvent::~QWheelEvent()
532 Constructs a wheel event object.
534 Use the QPoint-based constructor instead.
536 The \a pos provides the location of the mouse cursor
537 within the widget. The position in global coordinates is specified
538 by \a globalPos. \a delta contains the rotation distance, \a modifiers
539 holds the keyboard modifier flags at the time of the event, and
540 \a orient holds the wheel's orientation.
543 \sa pos(), pixelDelta(), angleDelta(), state()
545 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
546 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
547 Qt::Orientation orient)
548 : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons)
552 Constructs a wheel event object.
554 The \a pos provides the location of the mouse cursor
555 within the window. The position in global coordinates is specified
556 by \a globalPos. \a pixelDelta contains the scrolling distance
557 in pixels on screen, \a angleDelta contains the wheel rotation distance.
558 \a pixelDelta is optional and can be null.
560 \a modifiers holds the keyboard modifier flags at the time of the event.
562 \a pixelDelta contains the scrolling delta in pixels,
563 \a angleDelta contains the rotation distance, and
564 \a orient holds the wheel's orientation.
566 \sa pos(), globalPos(), delta(), state()
569 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
570 QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
571 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
572 : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
573 angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons)
577 #endif // QT_NO_WHEELEVENT
580 \fn QPoint QWheelEvent::pixelDelta() const
582 Returns the scrolling distance in pixels on screen. This value is
583 provided on platforms that support high-resolution pixel-based
584 delta values, such as Mac OS X. The value should be used directly
585 to scroll content on screen.
589 \snippet code/src_gui_kernel_qevent.cpp 0
593 \fn QPoint QWheelEvent::angleDelta() const
595 Returns the distance that the wheel is rotated, in eighths of a
596 degree. A positive value indicates that the wheel was rotated
597 forwards away from the user; a negative value indicates that the
598 wheel was rotated backwards toward the user.
600 Most mouse types work in steps of 15 degrees, in which case the
601 delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
603 However, some mice have finer-resolution wheels and send delta values
604 that are less than 120 units (less than 15 degrees). To support this
605 possibility, you can either cumulatively add the delta values from events
606 until the value of 120 is reached, then scroll the widget, or you can
607 partially scroll the widget in response to each wheel event.
611 \snippet code/src_gui_kernel_qevent.cpp 0
615 \fn int QWheelEvent::delta() const
617 This function has been deprecated, use pixelDelta() or angleDelta() instead.
621 \fn const QPoint &QWheelEvent::pos() const
623 Returns the position of the mouse cursor relative to the widget
624 that received the event.
626 If you move your widgets around in response to mouse events,
627 use globalPos() instead of this function.
629 \sa x(), y(), globalPos()
633 \fn int QWheelEvent::x() const
635 Returns the x position of the mouse cursor, relative to the
636 widget that received the event.
642 \fn int QWheelEvent::y() const
644 Returns the y position of the mouse cursor, relative to the
645 widget that received the event.
652 \fn const QPoint &QWheelEvent::globalPos() const
654 Returns the global position of the mouse pointer \e{at the time
655 of the event}. This is important on asynchronous window systems
656 such as X11; whenever you move your widgets around in response to
657 mouse events, globalPos() can differ a lot from the current
658 cursor position returned by QCursor::pos().
660 \sa globalX(), globalY()
664 \fn int QWheelEvent::globalX() const
666 Returns the global x position of the mouse cursor at the time of
669 \sa globalY(), globalPos()
673 \fn int QWheelEvent::globalY() const
675 Returns the global y position of the mouse cursor at the time of
678 \sa globalX(), globalPos()
683 \brief The QKeyEvent class describes a key event.
687 Key events are sent to the widget with keyboard input focus
688 when keys are pressed or released.
690 A key event contains a special accept flag that indicates whether
691 the receiver will handle the key event. You should call ignore()
692 if the key press or release event is not handled by your widget.
693 A key event is propagated up the parent widget chain until a
694 widget accepts it with accept() or an event filter consumes it.
695 Key events for multimedia keys are ignored by default. You should
696 call accept() if your widget handles those events.
698 The QWidget::setEnable() function can be used to enable or disable
699 mouse and keyboard events for a widget.
701 The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
702 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
705 \sa QFocusEvent, QWidget::grabKeyboard()
709 Constructs a key event object.
711 The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
712 or QEvent::ShortcutOverride.
714 Int \a key is the code for the Qt::Key that the event loop should listen
715 for. If \a key is 0, the event is not a result of a known key; for
716 example, it may be the result of a compose sequence or keyboard macro.
717 The \a modifiers holds the keyboard modifiers, and the given \a text
718 is the Unicode text that the key generated. If \a autorep is true,
719 isAutoRepeat() will be true. \a count is the number of keys involved
722 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
723 bool autorep, ushort count)
724 : QInputEvent(type, modifiers), txt(text), k(key),
725 nScanCode(0), nVirtualKey(0), nModifiers(0),
726 c(count), autor(autorep)
731 Constructs a key event object.
733 The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
734 or QEvent::ShortcutOverride.
736 Int \a key is the code for the Qt::Key that the event loop should listen
737 for. If \a key is 0, the event is not a result of a known key; for
738 example, it may be the result of a compose sequence or keyboard macro.
739 The \a modifiers holds the keyboard modifiers, and the given \a text
740 is the Unicode text that the key generated. If \a autorep is true,
741 isAutoRepeat() will be true. \a count is the number of keys involved
744 In addition to the normal key event data, also contains \a nativeScanCode,
745 \a nativeVirtualKey and \a nativeModifiers. This extra data is used by the
746 shortcut system, to determine which shortcuts to trigger.
748 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
749 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
750 const QString &text, bool autorep, ushort count)
751 : QInputEvent(type, modifiers), txt(text), k(key),
752 nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers),
753 c(count), autor(autorep)
761 QKeyEvent::~QKeyEvent()
766 \fn QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString& text, bool autorep, ushort count)
771 \fn bool QKeyEvent::hasExtendedInfo() const
776 \fn quint32 QKeyEvent::nativeScanCode() const
779 Returns the native scan code of the key event. If the key event
780 does not contain this data 0 is returned.
782 Note: The native scan code may be 0, even if the key event contains
783 extended information.
785 Note: On Mac OS/X, this function is not useful, because there is no
786 way to get the scan code from Carbon or Cocoa. The function always
787 returns 1 (or 0 in the case explained above).
791 \fn quint32 QKeyEvent::nativeVirtualKey() const
794 Returns the native virtual key, or key sym of the key event.
795 If the key event does not contain this data 0 is returned.
797 Note: The native virtual key may be 0, even if the key event contains extended information.
801 \fn quint32 QKeyEvent::nativeModifiers() const
804 Returns the native modifiers of a key event.
805 If the key event does not contain this data 0 is returned.
807 Note: The native modifiers may be 0, even if the key event contains extended information.
811 \fn int QKeyEvent::key() const
813 Returns the code of the key that was pressed or released.
815 See \l Qt::Key for the list of keyboard codes. These codes are
816 independent of the underlying window system. Note that this
817 function does not distinguish between capital and non-capital
818 letters, use the text() function (returning the Unicode text the
819 key generated) for this purpose.
821 A value of either 0 or Qt::Key_unknown means that the event is not
822 the result of a known key; for example, it may be the result of
823 a compose sequence, a keyboard macro, or due to key event
826 \sa Qt::WA_KeyCompression
830 \fn QString QKeyEvent::text() const
832 Returns the Unicode text that this key generated. The text
833 returned can be an empty string in cases
834 where modifier keys, such as Shift, Control, Alt, and Meta,
835 are being pressed or released. In such cases key() will contain
838 \sa Qt::WA_KeyCompression
842 Returns the keyboard modifier flags that existed immediately
843 after the event occurred.
845 \warning This function cannot always be trusted. The user can
846 confuse it by pressing both \uicontrol{Shift} keys simultaneously and
847 releasing one of them, for example.
849 \sa QApplication::keyboardModifiers()
851 //###### We must check with XGetModifierMapping
852 Qt::KeyboardModifiers QKeyEvent::modifiers() const
854 if (key() == Qt::Key_Shift)
855 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
856 if (key() == Qt::Key_Control)
857 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
858 if (key() == Qt::Key_Alt)
859 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
860 if (key() == Qt::Key_Meta)
861 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
862 return QInputEvent::modifiers();
865 #ifndef QT_NO_SHORTCUT
867 \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
870 Returns true if the key event matches the given standard \a key;
871 otherwise returns false.
873 bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
875 uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
876 const uint platform = QKeySequencePrivate::currentKeyPlatforms();
879 uint N = QKeySequencePrivate::numberOfKeyBindings;
883 while (first <= last) {
884 int mid = (first + last) / 2;
885 QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
887 if (searchkey > midVal.shortcut){
888 first = mid + 1; // Search in top half
890 else if (searchkey < midVal.shortcut){
891 last = mid - 1; // Search in bottom half
894 //found correct shortcut value, now we must check for platform match
895 if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
897 } else { //We may have several equal values for different platforms, so we must search in both directions
900 for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
901 QKeyBinding current = QKeySequencePrivate::keyBindings[i];
902 if (current.shortcut != searchkey)
904 else if (current.platform & platform && current.standardKey == matchKey)
909 for ( int i = mid - 1 ; i >= 0 ; --i) {
910 QKeyBinding current = QKeySequencePrivate::keyBindings[i];
911 if (current.shortcut != searchkey)
913 else if (current.platform & platform && current.standardKey == matchKey)
916 return false; //we could not find it among the matching keySequences
920 return false; //we could not find matching keySequences at all
922 #endif // QT_NO_SHORTCUT
926 \fn bool QKeyEvent::isAutoRepeat() const
928 Returns true if this event comes from an auto-repeating key;
929 returns false if it comes from an initial key press.
931 Note that if the event is a multiple-key compressed event that is
932 partly due to auto-repeat, this function could return either true
933 or false indeterminately.
937 \fn int QKeyEvent::count() const
939 Returns the number of keys involved in this event. If text()
940 is not empty, this is simply the length of the string.
942 \sa Qt::WA_KeyCompression
947 \brief The QFocusEvent class contains event parameters for widget focus
953 Focus events are sent to widgets when the keyboard input focus
954 changes. Focus events occur due to mouse actions, key presses
955 (such as \uicontrol{Tab} or \uicontrol{Backtab}), the window system, popup
956 menus, keyboard shortcuts, or other application-specific reasons.
957 The reason for a particular focus event is returned by reason()
958 in the appropriate event handler.
960 The event handlers QWidget::focusInEvent(),
961 QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
962 QGraphicsItem::focusOutEvent() receive focus events.
964 \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
968 Constructs a focus event object.
970 The \a type parameter must be either QEvent::FocusIn or
971 QEvent::FocusOut. The \a reason describes the cause of the change
974 QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
975 : QEvent(type), m_reason(reason)
981 QFocusEvent::~QFocusEvent()
986 Returns the reason for this focus event.
988 Qt::FocusReason QFocusEvent::reason() const
994 \fn bool QFocusEvent::gotFocus() const
996 Returns true if type() is QEvent::FocusIn; otherwise returns
1001 \fn bool QFocusEvent::lostFocus() const
1003 Returns true if type() is QEvent::FocusOut; otherwise returns
1010 \brief The QPaintEvent class contains event parameters for paint events.
1015 Paint events are sent to widgets that need to update themselves,
1016 for instance when part of a widget is exposed because a covering
1019 The event contains a region() that needs to be updated, and a
1020 rect() that is the bounding rectangle of that region. Both are
1021 provided because many widgets can't make much use of region(),
1022 and rect() can be much faster than region().boundingRect().
1024 \section1 Automatic Clipping
1026 Painting is clipped to region() during the processing of a paint
1027 event. This clipping is performed by Qt's paint system and is
1028 independent of any clipping that may be applied to a QPainter used to
1029 draw on the paint device.
1031 As a result, the value returned by QPainter::clipRegion() on
1032 a newly-constructed QPainter will not reflect the clip region that is
1033 used by the paint system.
1035 \sa QPainter, QWidget::update(), QWidget::repaint(),
1036 QWidget::paintEvent()
1040 Constructs a paint event object with the region that needs to
1041 be updated. The region is specified by \a paintRegion.
1043 QPaintEvent::QPaintEvent(const QRegion& paintRegion)
1044 : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
1048 Constructs a paint event object with the rectangle that needs
1049 to be updated. The region is specified by \a paintRect.
1051 QPaintEvent::QPaintEvent(const QRect &paintRect)
1052 : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
1059 QPaintEvent::~QPaintEvent()
1064 \fn const QRect &QPaintEvent::rect() const
1066 Returns the rectangle that needs to be updated.
1068 \sa region(), QPainter::setClipRect()
1072 \fn const QRegion &QPaintEvent::region() const
1074 Returns the region that needs to be updated.
1076 \sa rect(), QPainter::setClipRegion()
1082 \brief The QMoveEvent class contains event parameters for move events.
1087 Move events are sent to widgets that have been moved to a new
1088 position relative to their parent.
1090 The event handler QWidget::moveEvent() receives move events.
1092 \sa QWidget::move(), QWidget::setGeometry()
1096 Constructs a move event with the new and old widget positions,
1097 \a pos and \a oldPos respectively.
1099 QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
1100 : QEvent(Move), p(pos), oldp(oldPos)
1106 QMoveEvent::~QMoveEvent()
1111 \fn const QPoint &QMoveEvent::pos() const
1113 Returns the new position of the widget. This excludes the window
1114 frame for top level widgets.
1118 \fn const QPoint &QMoveEvent::oldPos() const
1120 Returns the old position of the widget.
1126 \brief The QExposeEvent class contains event parameters for expose events.
1131 Expose events are sent to windows when an area of the window is invalidated
1132 or window visibility in the windowing system changes.
1134 The event handler QWindow::exposeEvent() receives expose events.
1136 QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
1145 QExposeEvent::~QExposeEvent()
1151 \brief The QResizeEvent class contains event parameters for resize events.
1156 Resize events are sent to widgets that have been resized.
1158 The event handler QWidget::resizeEvent() receives resize events.
1160 \sa QWidget::resize(), QWidget::setGeometry()
1164 Constructs a resize event with the new and old widget sizes, \a
1165 size and \a oldSize respectively.
1167 QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
1168 : QEvent(Resize), s(size), olds(oldSize)
1174 QResizeEvent::~QResizeEvent()
1179 \fn const QSize &QResizeEvent::size() const
1181 Returns the new size of the widget. This is the same as
1186 \fn const QSize &QResizeEvent::oldSize() const
1188 Returns the old size of the widget.
1194 \brief The QCloseEvent class contains parameters that describe a close event.
1199 Close events are sent to widgets that the user wants to close,
1200 usually by choosing "Close" from the window menu, or by clicking
1201 the \uicontrol{X} title bar button. They are also sent when you call
1202 QWidget::close() to close a widget programmatically.
1204 Close events contain a flag that indicates whether the receiver
1205 wants the widget to be closed or not. When a widget accepts the
1206 close event, it is hidden (and destroyed if it was created with
1207 the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
1208 event nothing happens. (Under X11 it is possible that the window
1209 manager will forcibly close the window; but at the time of writing
1210 we are not aware of any window manager that does this.)
1212 The event handler QWidget::closeEvent() receives close events. The
1213 default implementation of this event handler accepts the close
1214 event. If you do not want your widget to be hidden, or want some
1215 special handing, you should reimplement the event handler and
1218 The \l{mainwindows/application#close event handler}{closeEvent() in the
1219 Application example} shows a close event handler that
1220 asks whether to save a document before closing.
1222 If you want the widget to be deleted when it is closed, create it
1223 with the Qt::WA_DeleteOnClose flag. This is very useful for
1224 independent top-level windows in a multi-window application.
1226 \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
1227 signal when they are deleted.
1229 If the last top-level window is closed, the
1230 QApplication::lastWindowClosed() signal is emitted.
1232 The isAccepted() function returns true if the event's receiver has
1233 agreed to close the widget; call accept() to agree to close the
1234 widget and call ignore() if the receiver of this event does not
1235 want the widget to be closed.
1237 \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
1238 QCoreApplication::exec(), QCoreApplication::quit(),
1239 QApplication::lastWindowClosed()
1243 Constructs a close event object.
1247 QCloseEvent::QCloseEvent()
1253 QCloseEvent::~QCloseEvent()
1258 \class QIconDragEvent
1259 \brief The QIconDragEvent class indicates that a main icon drag has begun.
1264 Icon drag events are sent to widgets when the main icon of a window
1265 has been dragged away. On Mac OS X, this happens when the proxy
1266 icon of a window is dragged off the title bar.
1268 It is normal to begin using drag and drop in response to this
1271 \sa {Drag and Drop}, QMimeData, QDrag
1275 Constructs an icon drag event object with the accept flag set to
1280 QIconDragEvent::QIconDragEvent()
1285 QIconDragEvent::~QIconDragEvent()
1290 \class QContextMenuEvent
1291 \brief The QContextMenuEvent class contains parameters that describe a context menu event.
1296 Context menu events are sent to widgets when a user performs
1297 an action associated with opening a context menu.
1298 The actions required to open context menus vary between platforms;
1299 for example, on Windows, pressing the menu button or clicking the
1300 right mouse button will cause this event to be sent.
1302 When this event occurs it is customary to show a QMenu with a
1303 context menu, if this is relevant to the context.
1305 Context menu events contain a special accept flag that indicates
1306 whether the receiver accepted the event. If the event handler does
1307 not accept the event then, if possible, whatever triggered the event will be
1308 handled as a regular input event.
1311 #ifndef QT_NO_CONTEXTMENU
1313 Constructs a context menu event object with the accept parameter
1316 The \a reason parameter must be QContextMenuEvent::Mouse or
1317 QContextMenuEvent::Keyboard.
1319 The \a pos parameter specifies the mouse position relative to the
1320 receiving widget. \a globalPos is the mouse position in absolute
1323 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
1324 : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
1328 Constructs a context menu event object with the accept parameter
1331 The \a reason parameter must be QContextMenuEvent::Mouse or
1332 QContextMenuEvent::Keyboard.
1334 The \a pos parameter specifies the mouse position relative to the
1335 receiving widget. \a globalPos is the mouse position in absolute
1336 coordinates. The \a modifiers holds the keyboard modifiers.
1338 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
1339 Qt::KeyboardModifiers modifiers)
1340 : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
1345 QContextMenuEvent::~QContextMenuEvent()
1349 Constructs a context menu event object with the accept parameter
1352 The \a reason parameter must be QContextMenuEvent::Mouse or
1353 QContextMenuEvent::Keyboard.
1355 The \a pos parameter specifies the mouse position relative to the
1358 The globalPos() is initialized to QCursor::pos(), which may not be
1359 appropriate. Use the other constructor to specify the global
1360 position explicitly.
1362 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
1363 : QInputEvent(ContextMenu), p(pos), reas(reason)
1365 gp = QCursor::pos();
1369 \fn const QPoint &QContextMenuEvent::pos() const
1371 Returns the position of the mouse pointer relative to the widget
1372 that received the event.
1374 \sa x(), y(), globalPos()
1378 \fn int QContextMenuEvent::x() const
1380 Returns the x position of the mouse pointer, relative to the
1381 widget that received the event.
1387 \fn int QContextMenuEvent::y() const
1389 Returns the y position of the mouse pointer, relative to the
1390 widget that received the event.
1396 \fn const QPoint &QContextMenuEvent::globalPos() const
1398 Returns the global position of the mouse pointer at the time of
1405 \fn int QContextMenuEvent::globalX() const
1407 Returns the global x position of the mouse pointer at the time of
1410 \sa globalY(), globalPos()
1414 \fn int QContextMenuEvent::globalY() const
1416 Returns the global y position of the mouse pointer at the time of
1419 \sa globalX(), globalPos()
1421 #endif // QT_NO_CONTEXTMENU
1424 \enum QContextMenuEvent::Reason
1426 This enum describes the reason why the event was sent.
1428 \value Mouse The mouse caused the event to be sent. Normally this
1429 means the right mouse button was clicked, but this is platform
1432 \value Keyboard The keyboard caused this event to be sent. On
1433 Windows, this means the menu button was pressed.
1435 \value Other The event was sent by some other means (i.e. not by
1436 the mouse or keyboard).
1441 \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
1443 Returns the reason for this context event.
1448 \class QInputMethodEvent
1449 \brief The QInputMethodEvent class provides parameters for input method events.
1454 Input method events are sent to widgets when an input method is
1455 used to enter text into a widget. Input methods are widely used
1456 to enter text for languages with non-Latin alphabets.
1458 Note that when creating custom text editing widgets, the
1459 Qt::WA_InputMethodEnabled window attribute must be set explicitly
1460 (using the QWidget::setAttribute() function) in order to receive
1461 input method events.
1463 The events are of interest to authors of keyboard entry widgets
1464 who want to be able to correctly handle languages with complex
1465 character input. Text input in such languages is usually a three
1469 \li \b{Starting to Compose}
1471 When the user presses the first key on a keyboard, an input
1472 context is created. This input context will contain a string
1473 of the typed characters.
1477 With every new key pressed, the input method will try to create a
1478 matching string for the text typed so far called preedit
1479 string. While the input context is active, the user can only move
1480 the cursor inside the string belonging to this input context.
1484 At some point, the user will activate a user interface component
1485 (perhaps using a particular key) where they can choose from a
1486 number of strings matching the text they have typed so far. The
1487 user can either confirm their choice cancel the input; in either
1488 case the input context will be closed.
1491 QInputMethodEvent models these three stages, and transfers the
1492 information needed to correctly render the intermediate result. A
1493 QInputMethodEvent has two main parameters: preeditString() and
1494 commitString(). The preeditString() parameter gives the currently
1495 active preedit string. The commitString() parameter gives a text
1496 that should get added to (or replace parts of) the text of the
1497 editor widget. It usually is a result of the input operations and
1498 has to be inserted to the widgets text directly before the preedit
1501 If the commitString() should replace parts of the of the text in
1502 the editor, replacementLength() will contain the number of
1503 characters to be replaced. replacementStart() contains the position
1504 at which characters are to be replaced relative from the start of
1507 A number of attributes control the visual appearance of the
1508 preedit string (the visual appearance of text outside the preedit
1509 string is controlled by the widget only). The AttributeType enum
1510 describes the different attributes that can be set.
1512 A class implementing QWidget::inputMethodEvent() or
1513 QGraphicsItem::inputMethodEvent() should at least understand and
1514 honor the \l TextFormat and \l Cursor attributes.
1516 Since input methods need to be able to query certain properties
1517 from the widget or graphics item, subclasses must also implement
1518 QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
1521 When receiving an input method event, the text widget has to performs the
1525 \li If the widget has selected text, the selected text should get
1528 \li Remove the text starting at replacementStart() with length
1529 replacementLength() and replace it by the commitString(). If
1530 replacementLength() is 0, replacementStart() gives the insertion
1531 position for the commitString().
1533 When doing replacement the area of the preedit
1534 string is ignored, thus a replacement starting at -1 with a length
1535 of 2 will remove the last character before the preedit string and
1536 the first character afterwards, and insert the commit string
1537 directly before the preedit string.
1539 If the widget implements undo/redo, this operation gets added to
1542 \li If there is no current preedit string, insert the
1543 preeditString() at the current cursor position; otherwise replace
1544 the previous preeditString with the one received from this event.
1546 If the widget implements undo/redo, the preeditString() should not
1547 influence the undo/redo stack in any way.
1549 The widget should examine the list of attributes to apply to the
1550 preedit string. It has to understand at least the TextFormat and
1551 Cursor attributes and render them as specified.
1558 \enum QInputMethodEvent::AttributeType
1561 A QTextCharFormat for the part of the preedit string specified by
1562 start and length. value contains a QVariant of type QTextFormat
1563 specifying rendering of this part of the preedit string. There
1564 should be at most one format for every part of the preedit
1565 string. If several are specified for any character in the string the
1566 behaviour is undefined. A conforming implementation has to at least
1567 honor the backgroundColor, textColor and fontUnderline properties
1570 \value Cursor If set, a cursor should be shown inside the preedit
1571 string at position start. The length variable determines whether
1572 the cursor is visible or not. If the length is 0 the cursor is
1573 invisible. If value is a QVariant of type QColor this color will
1574 be used for rendering the cursor, otherwise the color of the
1575 surrounding text will be used. There should be at most one Cursor
1576 attribute per event. If several are specified the behaviour is
1580 The variant contains a QLocale object specifying the language of a
1581 certain part of the preedit string. There should be at most one
1582 language set for every part of the preedit string. If several are
1583 specified for any character in the string the behavior is undefined.
1586 The ruby text for a part of the preedit string. There should be at
1587 most one ruby text set for every part of the preedit string. If
1588 several are specified for any character in the string the behaviour
1592 If set, the edit cursor should be moved to the specified position
1593 in the editor text contents. In contrast with \c Cursor, this
1594 attribute does not work on the preedit text, but on the surrounding
1595 text. The cursor will be moved after the commit string has been
1596 committed, and the preedit string will be located at the new edit
1598 The start position specifies the new position and the length
1599 variable can be used to set a selection starting from that point.
1600 The value is unused.
1606 \class QInputMethodEvent::Attribute
1607 \brief The QInputMethodEvent::Attribute class stores an input method attribute.
1611 \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
1613 Constructs an input method attribute. \a type specifies the type
1614 of attribute, \a start and \a length the position of the
1615 attribute, and \a value the value of the attribute.
1619 Constructs an event of type QEvent::InputMethod. The
1620 attributes(), preeditString(), commitString(), replacementStart(),
1621 and replacementLength() are initialized to default values.
1623 \sa setCommitString()
1625 QInputMethodEvent::QInputMethodEvent()
1626 : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
1631 Construcs an event of type QEvent::InputMethod. The
1632 preedit text is set to \a preeditText, the attributes to
1635 The commitString(), replacementStart(), and replacementLength()
1636 values can be set using setCommitString().
1638 \sa preeditString(), attributes()
1640 QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
1641 : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
1642 replace_from(0), replace_length(0)
1647 Constructs a copy of \a other.
1649 QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
1650 : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
1651 commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
1656 Sets the commit string to \a commitString.
1658 The commit string is the text that should get added to (or
1659 replace parts of) the text of the editor widget. It usually is a
1660 result of the input operations and has to be inserted to the
1661 widgets text directly before the preedit string.
1663 If the commit string should replace parts of the of the text in
1664 the editor, \a replaceLength specifies the number of
1665 characters to be replaced. \a replaceFrom specifies the position
1666 at which characters are to be replaced relative from the start of
1669 \sa commitString(), replacementStart(), replacementLength()
1671 void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
1673 commit = commitString;
1674 replace_from = replaceFrom;
1675 replace_length = replaceLength;
1679 \fn const QList<Attribute> &QInputMethodEvent::attributes() const
1681 Returns the list of attributes passed to the QInputMethodEvent
1682 constructor. The attributes control the visual appearance of the
1683 preedit string (the visual appearance of text outside the preedit
1684 string is controlled by the widget only).
1686 \sa preeditString(), Attribute
1690 \fn const QString &QInputMethodEvent::preeditString() const
1692 Returns the preedit text, i.e. the text before the user started
1695 \sa commitString(), attributes()
1699 \fn const QString &QInputMethodEvent::commitString() const
1701 Returns the text that should get added to (or replace parts of)
1702 the text of the editor widget. It usually is a result of the
1703 input operations and has to be inserted to the widgets text
1704 directly before the preedit string.
1706 \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
1710 \fn int QInputMethodEvent::replacementStart() const
1712 Returns the position at which characters are to be replaced relative
1713 from the start of the preedit string.
1715 \sa replacementLength(), setCommitString()
1719 \fn int QInputMethodEvent::replacementLength() const
1721 Returns the number of characters to be replaced in the preedit
1724 \sa replacementStart(), setCommitString()
1728 \class QInputMethodQueryEvent
1732 \brief This event is sent by the input context to input objects.
1735 input method to query a set of properties of the object to be
1736 able to support complex input method operations as support for
1737 surrounding text and reconversions.
1739 queries() specifies which properties are queried.
1741 The object should call setValue() on the event to fill in the requested
1742 data before calling accept().
1746 \fn Qt::InputMethodQueries QInputMethodQueryEvent::queries() const
1748 Returns the properties queried by the event.
1752 Constructs a query event for properties given by \a queries.
1754 QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQueries queries)
1755 : QEvent(InputMethodQuery),
1763 QInputMethodQueryEvent::~QInputMethodQueryEvent()
1768 Sets query property to given value.
1770 void QInputMethodQueryEvent::setValue(Qt::InputMethodQuery query, const QVariant &value)
1772 for (int i = 0; i < m_values.size(); ++i) {
1773 if (m_values.at(i).query == query) {
1774 m_values[i].value = value;
1778 QueryPair pair = { query, value };
1779 m_values.append(pair);
1783 Returns value of a query property.
1785 QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
1787 for (int i = 0; i < m_values.size(); ++i)
1788 if (m_values.at(i).query == query)
1789 return m_values.at(i).value;
1793 #ifndef QT_NO_TABLETEVENT
1797 \brief The QTabletEvent class contains parameters that describe a Tablet event.
1802 Tablet Events are generated from a Wacom tablet. Most of the time you will
1803 want to deal with events from the tablet as if they were events from a
1804 mouse; for example, you would retrieve the cursor position with x(), y(),
1805 pos(), globalX(), globalY(), and globalPos(). In some situations you may
1806 wish to retrieve the extra information provided by the tablet device
1807 driver; for example, you might want to do subpixeling with higher
1808 resolution coordinates or you may want to adjust color brightness based on
1809 pressure. QTabletEvent allows you to read the pressure(), the xTilt(), and
1810 yTilt(), as well as the type of device being used with device() (see
1811 \l{TabletDevice}). It can also give you the minimum and maximum values for
1812 each device's pressure and high resolution coordinates.
1814 A tablet event contains a special accept flag that indicates whether the
1815 receiver wants the event. You should call QTabletEvent::accept() if you
1816 handle the tablet event; otherwise it will be sent to the parent widget.
1817 The exception are TabletEnterProximity and TabletLeaveProximity events,
1818 these are only sent to QApplication and don't check whether or not they are
1821 The QWidget::setEnabled() function can be used to enable or
1822 disable mouse and keyboard events for a widget.
1824 The event handler QWidget::tabletEvent() receives all three types of
1825 tablet events. Qt will first send a tabletEvent then, if it is not
1826 accepted, it will send a mouse event. This allows applications that
1827 don't utilize tablets to use a tablet like a mouse, while also
1828 enabling those who want to use both tablets and mouses differently.
1830 \section1 Notes for X11 Users
1832 Qt uses the following hard-coded names to identify tablet
1833 devices from the xorg.conf file on X11 (apart from IRIX):
1834 'stylus', 'pen', and 'eraser'. If the devices have other names,
1835 they will not be picked up Qt.
1839 \enum QTabletEvent::TabletDevice
1841 This enum defines what type of device is generating the event.
1843 \value NoDevice No device, or an unknown device.
1844 \value Puck A Puck (a device that is similar to a flat mouse with
1845 a transparent circle with cross-hairs).
1846 \value Stylus A Stylus.
1847 \value Airbrush An airbrush
1848 \value FourDMouse A 4D Mouse.
1849 \value RotationStylus A special stylus that also knows about rotation
1850 (a 6D stylus). \since 4.1
1851 \omitvalue XFreeEraser
1855 \enum QTabletEvent::PointerType
1857 This enum defines what type of point is generating the event.
1859 \value UnknownPointer An unknown device.
1860 \value Pen Tip end of a stylus-like device (the narrow end of the pen).
1861 \value Cursor Any puck-like device.
1862 \value Eraser Eraser end of a stylus-like device (the broad end of the pen).
1868 Construct a tablet event of the given \a type.
1870 The \a pos parameter indicates where the event occurred in the
1871 widget; \a globalPos is the corresponding position in absolute
1872 coordinates. The \a hiResGlobalPos contains a high resolution
1873 measurement of the position.
1875 \a pressure contains the pressure exerted on the \a device.
1877 \a pointerType describes the type of pen that is being used.
1879 \a xTilt and \a yTilt contain the device's degree of tilt from the
1880 x and y axes respectively.
1882 \a keyState specifies which keyboard modifiers are pressed (e.g.,
1885 The \a uniqueID parameter contains the unique ID for the current device.
1887 The \a z parameter contains the coordinate of the device on the tablet, this
1888 is usually given by a wheel on 4D mouse. If the device does not support a
1889 Z-axis, pass zero here.
1891 The \a tangentialPressure parameter contins the tangential pressure of an air
1892 brush. If the device does not support tangential pressure, pass 0 here.
1894 \a rotation contains the device's rotation in degrees. 4D mice support
1895 rotation. If the device does not support rotation, pass 0 here.
1897 \sa pos(), globalPos(), device(), pressure(), xTilt(), yTilt(), uniqueId(), rotation(),
1898 tangentialPressure(), z()
1901 QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
1902 int device, int pointerType,
1903 qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
1904 qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
1905 : QInputEvent(type, keyState),
1909 mPointerType(pointerType),
1914 mTangential(tangentialPressure),
1924 QTabletEvent::~QTabletEvent()
1929 \fn TabletDevices QTabletEvent::device() const
1931 Returns the type of device that generated the event.
1937 \fn PointerType QTabletEvent::pointerType() const
1939 Returns the type of point that generated the event.
1943 \fn qreal QTabletEvent::tangentialPressure() const
1945 Returns the tangential pressure for the device. This is typically given by a finger
1946 wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a
1947 neutral position. Current airbrushes can only move in the positive
1948 direction from the neutrual position. If the device does not support
1949 tangential pressure, this value is always 0.0.
1955 \fn qreal QTabletEvent::rotation() const
1957 Returns the rotation of the current device in degress. This is usually
1958 given by a 4D Mouse. If the device doesn't support rotation this value is
1964 \fn qreal QTabletEvent::pressure() const
1966 Returns the pressure for the device. 0.0 indicates that the stylus is not
1967 on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
1969 \sa tangentialPressure()
1973 \fn int QTabletEvent::xTilt() const
1975 Returns the angle between the device (a pen, for example) and the
1976 perpendicular in the direction of the x axis.
1977 Positive values are towards the tablet's physical right. The angle
1978 is in the range -60 to +60 degrees.
1980 \image qtabletevent-tilt.png
1986 \fn int QTabletEvent::yTilt() const
1988 Returns the angle between the device (a pen, for example) and the
1989 perpendicular in the direction of the y axis.
1990 Positive values are towards the bottom of the tablet. The angle is
1991 within the range -60 to +60 degrees.
1997 \fn const QPoint &QTabletEvent::pos() const
1999 Returns the position of the device, relative to the widget that
2002 If you move widgets around in response to mouse events, use
2003 globalPos() instead of this function.
2005 \sa x(), y(), globalPos()
2009 \fn int QTabletEvent::x() const
2011 Returns the x position of the device, relative to the widget that
2018 \fn int QTabletEvent::y() const
2020 Returns the y position of the device, relative to the widget that
2027 \fn int QTabletEvent::z() const
2029 Returns the z position of the device. Typically this is represented by a
2030 wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
2031 always zero. This is \b not the same as pressure.
2037 \fn const QPoint &QTabletEvent::globalPos() const
2039 Returns the global position of the device \e{at the time of the
2040 event}. This is important on asynchronous windows systems like X11;
2041 whenever you move your widgets around in response to mouse events,
2042 globalPos() can differ significantly from the current position
2045 \sa globalX(), globalY(), hiResGlobalPos()
2049 \fn int QTabletEvent::globalX() const
2051 Returns the global x position of the mouse pointer at the time of
2054 \sa globalY(), globalPos(), hiResGlobalX()
2058 \fn int QTabletEvent::globalY() const
2060 Returns the global y position of the tablet device at the time of
2063 \sa globalX(), globalPos(), hiResGlobalY()
2067 \fn qint64 QTabletEvent::uniqueId() const
2069 Returns a unique ID for the current device, making it possible
2070 to differentiate between multiple devices being used at the same
2073 Support of this feature is dependent on the tablet.
2075 Values for the same device may vary from OS to OS.
2077 Later versions of the Wacom driver for Linux will now report
2078 the ID information. If you have a tablet that supports unique ID
2079 and are not getting the information on Linux, consider upgrading
2082 As of Qt 4.2, the unique ID is the same regardless of the orientation
2083 of the pen. Earlier versions would report a different value when using
2084 the eraser-end versus the pen-end of the stylus on some OS's.
2090 \fn const QPointF &QTabletEvent::hiResGlobalPos() const
2092 The high precision coordinates delivered from the tablet expressed.
2093 Sub pixeling information is in the fractional part of the QPointF.
2095 \sa globalPos(), hiResGlobalX(), hiResGlobalY()
2099 \fn qreal &QTabletEvent::hiResGlobalX() const
2101 The high precision x position of the tablet device.
2105 \fn qreal &QTabletEvent::hiResGlobalY() const
2107 The high precision y position of the tablet device.
2110 #endif // QT_NO_TABLETEVENT
2112 #ifndef QT_NO_DRAGANDDROP
2114 Creates a QDragMoveEvent of the required \a type indicating
2115 that the mouse is at position \a pos given within a widget.
2117 The mouse and keyboard states are specified by \a buttons and
2118 \a modifiers, and the \a actions describe the types of drag
2119 and drop operation that are possible.
2120 The drag data is passed as MIME-encoded information in \a data.
2122 \warning Do not attempt to create a QDragMoveEvent yourself.
2123 These objects rely on Qt's internal state.
2125 QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2126 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2127 : QDropEvent(pos, actions, data, buttons, modifiers, type)
2128 , rect(pos, QSize(1, 1))
2134 QDragMoveEvent::~QDragMoveEvent()
2139 \fn void QDragMoveEvent::accept(const QRect &rectangle)
2141 The same as accept(), but also notifies that future moves will
2142 also be acceptable if they remain within the \a rectangle
2143 given on the widget. This can improve performance, but may
2144 also be ignored by the underlying system.
2146 If the rectangle is empty, drag move events will be sent
2147 continuously. This is useful if the source is scrolling in a
2152 \fn void QDragMoveEvent::accept()
2156 Calls QDropEvent::accept().
2160 \fn void QDragMoveEvent::ignore()
2164 Calls QDropEvent::ignore().
2168 \fn void QDragMoveEvent::ignore(const QRect &rectangle)
2170 The opposite of the accept(const QRect&) function.
2171 Moves within the \a rectangle are not acceptable, and will be
2176 \fn QRect QDragMoveEvent::answerRect() const
2178 Returns the rectangle in the widget where the drop will occur if accepted.
2179 You can use this information to restrict drops to certain places on the
2187 \ingroup draganddrop
2190 \brief The QDropEvent class provides an event which is sent when a
2191 drag and drop action is completed.
2193 When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
2194 receive this event if it has accepted the most recent QDragEnterEvent or
2195 QDragMoveEvent sent to it.
2197 The drop event contains a proposed action, available from proposedAction(), for
2198 the widget to either accept or ignore. If the action can be handled by the
2199 widget, you should call the acceptProposedAction() function. Since the
2200 proposed action can be a combination of \l Qt::DropAction values, it may be
2201 useful to either select one of these values as a default action or ask
2202 the user to select their preferred action.
2204 If the proposed drop action is not suitable, perhaps because your custom
2205 widget does not support that action, you can replace it with any of the
2206 \l{possibleActions()}{possible drop actions} by calling setDropAction()
2207 with your preferred action. If you set a value that is not present in the
2208 bitwise OR combination of values returned by possibleActions(), the default
2209 copy action will be used. Once a replacement drop action has been set, call
2210 accept() instead of acceptProposedAction() to complete the drop operation.
2212 The mimeData() function provides the data dropped on the widget in a QMimeData
2213 object. This contains information about the MIME type of the data in addition to
2216 \sa QMimeData, QDrag, {Drag and Drop}
2220 \fn const QMimeData *QDropEvent::mimeData() const
2222 Returns the data that was dropped on the widget and its associated MIME
2227 Constructs a drop event of a certain \a type corresponding to a
2228 drop at the point specified by \a pos in the destination widget's
2231 The \a actions indicate which types of drag and drop operation can
2232 be performed, and the drag data is stored as MIME-encoded data in \a data.
2234 The states of the mouse buttons and keyboard modifiers at the time of
2235 the drop are specified by \a buttons and \a modifiers.
2236 */ // ### pos is in which coordinate system?
2237 QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
2238 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2239 : QEvent(type), p(pos), mouseState(buttons),
2240 modState(modifiers), act(actions),
2243 default_action = QGuiApplicationPrivate::platformIntegration()->drag()->defaultAction(act, modifiers);
2244 drop_action = default_action;
2249 QDropEvent::~QDropEvent()
2255 If the source of the drag operation is a widget in this
2256 application, this function returns that source; otherwise it
2257 returns 0. The source of the operation is the first parameter to
2258 the QDrag object used instantiate the drag.
2260 This is useful if your widget needs special behavior when dragging
2265 QObject* QDropEvent::source() const
2267 if (const QDragManager *manager = QDragManager::self())
2268 return manager->source();
2273 void QDropEvent::setDropAction(Qt::DropAction action)
2275 if (!(action & act) && action != Qt::IgnoreAction)
2276 action = default_action;
2277 drop_action = action;
2281 \fn const QPoint& QDropEvent::pos() const
2283 Returns the position where the drop was made.
2287 \fn Qt::MouseButtons QDropEvent::mouseButtons() const
2289 Returns the mouse buttons that are pressed..
2293 \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
2295 Returns the modifier keys that are pressed.
2299 \fn void QDropEvent::setDropAction(Qt::DropAction action)
2301 Sets the \a action to be performed on the data by the target.
2302 Use this to override the \l{proposedAction()}{proposed action}
2303 with one of the \l{possibleActions()}{possible actions}.
2305 If you set a drop action that is not one of the possible actions, the
2306 drag and drop operation will default to a copy operation.
2308 Once you have supplied a replacement drop action, call accept()
2309 instead of acceptProposedAction().
2315 \fn Qt::DropAction QDropEvent::dropAction() const
2317 Returns the action to be performed on the data by the target. This may be
2318 different from the action supplied in proposedAction() if you have called
2319 setDropAction() to explicitly choose a drop action.
2325 \fn Qt::DropActions QDropEvent::possibleActions() const
2327 Returns an OR-combination of possible drop actions.
2333 \fn Qt::DropAction QDropEvent::proposedAction() const
2335 Returns the proposed drop action.
2341 \fn void QDropEvent::acceptProposedAction()
2343 Sets the drop action to be the proposed action.
2345 \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
2349 \class QDragEnterEvent
2350 \brief The QDragEnterEvent class provides an event which is sent
2351 to a widget when a drag and drop action enters it.
2354 \ingroup draganddrop
2357 A widget must accept this event in order to receive the \l
2358 {QDragMoveEvent}{drag move events} that are sent while the drag
2359 and drop action is in progress. The drag enter event is always
2360 immediately followed by a drag move event.
2362 QDragEnterEvent inherits most of its functionality from
2363 QDragMoveEvent, which in turn inherits most of its functionality
2366 \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
2370 Constructs a QDragEnterEvent that represents a drag entering a
2371 widget at the given \a point with mouse and keyboard states specified by
2372 \a buttons and \a modifiers.
2374 The drag data is passed as MIME-encoded information in \a data, and the
2375 specified \a actions describe the possible types of drag and drop
2376 operation that can be performed.
2378 \warning Do not create a QDragEnterEvent yourself since these
2379 objects rely on Qt's internal state.
2381 QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
2382 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
2383 : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
2388 QDragEnterEvent::~QDragEnterEvent()
2393 \class QDragMoveEvent
2394 \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
2397 \ingroup draganddrop
2400 A widget will receive drag move events repeatedly while the drag
2401 is within its boundaries, if it accepts
2402 \l{QWidget::setAcceptDrops()}{drop events} and \l
2403 {QWidget::dragEnterEvent()}{enter events}. The widget should
2404 examine the event to see what kind of data it
2405 \l{QDragMoveEvent::provides()}{provides}, and call the accept()
2406 function to accept the drop if appropriate.
2408 The rectangle supplied by the answerRect() function can be used to restrict
2409 drops to certain parts of the widget. For example, we can check whether the
2410 rectangle intersects with the geometry of a certain child widget and only
2411 call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
2414 Note that this class inherits most of its functionality from
2417 \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
2421 \class QDragLeaveEvent
2422 \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
2425 \ingroup draganddrop
2428 This event is always preceded by a QDragEnterEvent and a series
2429 of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
2432 \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
2436 Constructs a QDragLeaveEvent.
2438 \warning Do not create a QDragLeaveEvent yourself since these
2439 objects rely on Qt's internal state.
2441 QDragLeaveEvent::QDragLeaveEvent()
2447 QDragLeaveEvent::~QDragLeaveEvent()
2450 #endif // QT_NO_DRAGANDDROP
2454 \brief The QHelpEvent class provides an event that is used to request helpful information
2455 about a particular point in a widget.
2461 This event can be intercepted in applications to provide tooltips
2462 or "What's This?" help for custom widgets. The type() can be
2463 either QEvent::ToolTip or QEvent::WhatsThis.
2465 \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
2469 Constructs a help event with the given \a type corresponding to the
2470 widget-relative position specified by \a pos and the global position
2471 specified by \a globalPos.
2473 \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
2475 \sa pos(), globalPos()
2477 QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
2478 : QEvent(type), p(pos), gp(globalPos)
2482 \fn int QHelpEvent::x() const
2486 \sa y(), pos(), globalPos()
2490 \fn int QHelpEvent::y() const
2494 \sa x(), pos(), globalPos()
2498 \fn int QHelpEvent::globalX() const
2500 Same as globalPos().x().
2502 \sa x(), globalY(), globalPos()
2506 \fn int QHelpEvent::globalY() const
2508 Same as globalPos().y().
2510 \sa y(), globalX(), globalPos()
2514 \fn const QPoint &QHelpEvent::pos() const
2516 Returns the mouse cursor position when the event was generated,
2517 relative to the widget to which the event is dispatched.
2519 \sa globalPos(), x(), y()
2523 \fn const QPoint &QHelpEvent::globalPos() const
2525 Returns the mouse cursor position when the event was generated
2526 in global coordinates.
2528 \sa pos(), globalX(), globalY()
2533 QHelpEvent::~QHelpEvent()
2537 #ifndef QT_NO_STATUSTIP
2540 \class QStatusTipEvent
2541 \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
2547 Status tips can be set on a widget using the
2548 QWidget::setStatusTip() function. They are shown in the status
2549 bar when the mouse cursor enters the widget. For example:
2554 \snippet qstatustipevent/main.cpp 1
2556 \snippet qstatustipevent/main.cpp 3
2558 \image qstatustipevent-widget.png Widget with status tip.
2561 Status tips can also be set on actions using the
2562 QAction::setStatusTip() function:
2567 \snippet qstatustipevent/main.cpp 0
2568 \snippet qstatustipevent/main.cpp 2
2570 \snippet qstatustipevent/main.cpp 3
2572 \image qstatustipevent-action.png Action with status tip.
2575 Finally, status tips are supported for the item view classes
2576 through the Qt::StatusTipRole enum value.
2578 \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
2582 Constructs a status tip event with the text specified by \a tip.
2586 QStatusTipEvent::QStatusTipEvent(const QString &tip)
2587 : QEvent(StatusTip), s(tip)
2592 QStatusTipEvent::~QStatusTipEvent()
2597 \fn QString QStatusTipEvent::tip() const
2599 Returns the message to show in the status bar.
2601 \sa QStatusBar::showMessage()
2604 #endif // QT_NO_STATUSTIP
2606 #ifndef QT_NO_WHATSTHIS
2609 \class QWhatsThisClickedEvent
2610 \brief The QWhatsThisClickedEvent class provides an event that
2611 can be used to handle hyperlinks in a "What's This?" text.
2617 \sa QWhatsThis, QHelpEvent, QStatusTipEvent
2621 Constructs an event containing a URL specified by \a href when a link
2622 is clicked in a "What's This?" message.
2626 QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
2627 : QEvent(WhatsThisClicked), s(href)
2632 QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
2637 \fn QString QWhatsThisClickedEvent::href() const
2639 Returns the URL that was clicked by the user in the "What's
2643 #endif // QT_NO_WHATSTHIS
2645 #ifndef QT_NO_ACTION
2649 \brief The QActionEvent class provides an event that is generated
2650 when a QAction is added, removed, or changed.
2655 Actions can be added to widgets using QWidget::addAction(). This
2656 generates an \l ActionAdded event, which you can handle to provide
2657 custom behavior. For example, QToolBar reimplements
2658 QWidget::actionEvent() to create \l{QToolButton}s for the
2661 \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
2665 Constructs an action event. The \a type can be \l ActionChanged,
2666 \l ActionAdded, or \l ActionRemoved.
2668 \a action is the action that is changed, added, or removed. If \a
2669 type is ActionAdded, the action is to be inserted before the
2670 action \a before. If \a before is 0, the action is appended.
2672 QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
2673 : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
2678 QActionEvent::~QActionEvent()
2683 \fn QAction *QActionEvent::action() const
2685 Returns the action that is changed, added, or removed.
2691 \fn QAction *QActionEvent::before() const
2693 If type() is \l ActionAdded, returns the action that should
2694 appear before action(). If this function returns 0, the action
2695 should be appended to already existing actions on the same
2698 \sa action(), QWidget::actions()
2701 #endif // QT_NO_ACTION
2705 \brief The QHideEvent class provides an event which is sent after a widget is hidden.
2710 This event is sent just before QWidget::hide() returns, and also
2711 when a top-level window has been hidden (iconified) by the user.
2713 If spontaneous() is true, the event originated outside the
2714 application. In this case, the user hid the window using the
2715 window manager controls, either by iconifying the window or by
2716 switching to another virtual desktop where the window isn't
2717 visible. The window will become hidden but not withdrawn. If the
2718 window was iconified, QWidget::isMinimized() returns true.
2724 Constructs a QHideEvent.
2726 QHideEvent::QHideEvent()
2732 QHideEvent::~QHideEvent()
2738 \brief The QShowEvent class provides an event that is sent when a widget is shown.
2743 There are two kinds of show events: show events caused by the
2744 window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
2745 show events are sent just after the window system shows the
2746 window; they are also sent when a top-level window is redisplayed
2747 after being iconified. Internal show events are delivered just
2748 before the widget becomes visible.
2754 Constructs a QShowEvent.
2756 QShowEvent::QShowEvent()
2762 QShowEvent::~QShowEvent()
2767 \class QFileOpenEvent
2768 \brief The QFileOpenEvent class provides an event that will be
2769 sent when there is a request to open a file or a URL.
2774 File open events will be sent to the QApplication::instance()
2775 when the operating system requests that a file or URL should be opened.
2776 This is a high-level event that can be caused by different user actions
2777 depending on the user's desktop environment; for example, double
2778 clicking on an file icon in the Finder on Mac OS X.
2780 This event is only used to notify the application of a request.
2781 It may be safely ignored.
2783 \note This class is currently supported for Mac OS X only.
2789 Constructs a file open event for the given \a file.
2791 QFileOpenEvent::QFileOpenEvent(const QString &file)
2792 : QEvent(FileOpen), f(file), m_url(QUrl::fromLocalFile(file))
2799 Constructs a file open event for the given \a url.
2801 QFileOpenEvent::QFileOpenEvent(const QUrl &url)
2802 : QEvent(FileOpen), f(url.toLocalFile()), m_url(url)
2809 QFileOpenEvent::~QFileOpenEvent()
2814 \fn QString QFileOpenEvent::file() const
2816 Returns the file that is being opened.
2820 \fn QUrl QFileOpenEvent::url() const
2822 Returns the url that is being opened.
2828 \fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2830 Opens a QFile on the \a file referenced by this event in the mode specified
2831 by \a flags. Returns true if successful; otherwise returns false.
2833 This is necessary as some files cannot be opened by name, but require specific
2834 information stored in this event.
2838 bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2840 file.setFileName(f);
2841 return file.open(flags);
2844 #ifndef QT_NO_TOOLBAR
2847 \class QToolBarChangeEvent
2848 \brief The QToolBarChangeEvent class provides an event that is
2849 sent whenever a the toolbar button is clicked on Mac OS X.
2854 The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
2855 OS X, this is the long oblong button on the right side of the window
2856 title bar. The default implementation is to toggle the appearance (hidden or
2857 shown) of the associated toolbars for the window.
2863 Construct a QToolBarChangeEvent given the current button state in \a state.
2865 QToolBarChangeEvent::QToolBarChangeEvent(bool t)
2866 : QEvent(ToolBarChange), tog(t)
2871 QToolBarChangeEvent::~QToolBarChangeEvent()
2876 \fn bool QToolBarChangeEvent::toggle() const
2881 \fn Qt::ButtonState QToolBarChangeEvent::state() const
2883 Returns the keyboard modifier flags at the time of the event.
2885 The returned value is a selection of the following values,
2886 combined using the OR operator:
2887 Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
2890 #endif // QT_NO_TOOLBAR
2892 #ifndef QT_NO_SHORTCUT
2895 Constructs a shortcut event for the given \a key press,
2896 associated with the QShortcut ID \a id.
2898 \a ambiguous specifies whether there is more than one QShortcut
2899 for the same key sequence.
2901 QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
2902 : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
2907 Destroys the event object.
2909 QShortcutEvent::~QShortcutEvent()
2913 #endif // QT_NO_SHORTCUT
2915 #ifndef QT_NO_DEBUG_STREAM
2916 QDebug operator<<(QDebug dbg, const QEvent *e) {
2917 // More useful event output could be added here
2919 return dbg << "QEvent(this = 0x0)";
2921 switch (e->type()) {
2925 case QEvent::MouseButtonPress:
2926 case QEvent::MouseMove:
2927 case QEvent::MouseButtonRelease:
2928 case QEvent::MouseButtonDblClick:
2930 const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
2931 switch(me->type()) {
2932 case QEvent::MouseButtonPress:
2933 n = "MouseButtonPress";
2935 case QEvent::MouseMove:
2938 case QEvent::MouseButtonRelease:
2939 n = "MouseButtonRelease";
2941 case QEvent::MouseButtonDblClick:
2943 n = "MouseButtonDblClick";
2946 dbg.nospace() << "QMouseEvent(" << n
2947 << ", " << me->button()
2948 << ", " << hex << (int)me->buttons()
2949 << ", " << hex << (int)me->modifiers()
2954 #ifndef QT_NO_TOOLTIP
2955 case QEvent::ToolTip:
2959 case QEvent::WindowActivate:
2960 n = "WindowActivate";
2962 case QEvent::WindowDeactivate:
2963 n = "WindowDeactivate";
2965 case QEvent::ActivationChange:
2966 n = "ActivationChange";
2968 #ifndef QT_NO_WHEELEVENT
2970 dbg.nospace() << "QWheelEvent("
2971 << static_cast<const QWheelEvent *>(e)->pixelDelta()
2972 << static_cast<const QWheelEvent *>(e)->angleDelta()
2976 case QEvent::KeyPress:
2977 case QEvent::KeyRelease:
2978 case QEvent::ShortcutOverride:
2980 const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
2981 switch(ke->type()) {
2982 case QEvent::ShortcutOverride:
2983 n = "ShortcutOverride";
2985 case QEvent::KeyRelease:
2988 case QEvent::KeyPress:
2993 dbg.nospace() << "QKeyEvent(" << n
2994 << ", " << hex << ke->key()
2995 << ", " << hex << (int)ke->modifiers()
2996 << ", \"" << ke->text()
2997 << "\", " << ke->isAutoRepeat()
2998 << ", " << ke->count()
3002 case QEvent::FocusIn:
3005 case QEvent::FocusOut:
3014 case QEvent::PaletteChange:
3015 n = "PaletteChange";
3017 case QEvent::PolishRequest:
3018 n = "PolishRequest";
3020 case QEvent::Polish:
3023 case QEvent::UpdateRequest:
3024 n = "UpdateRequest";
3032 case QEvent::Resize:
3035 case QEvent::Create:
3038 case QEvent::Destroy:
3047 case QEvent::FileOpen:
3053 case QEvent::ShowToParent:
3059 case QEvent::HideToParent:
3065 case QEvent::ParentChange:
3068 case QEvent::ParentAboutToChange:
3069 n = "ParentAboutToChange";
3071 case QEvent::HoverEnter:
3074 case QEvent::HoverMove:
3077 case QEvent::HoverLeave:
3080 case QEvent::ZOrderChange:
3083 case QEvent::StyleChange:
3086 case QEvent::DragEnter:
3089 case QEvent::DragMove:
3092 case QEvent::DragLeave:
3098 case QEvent::GraphicsSceneMouseMove:
3099 n = "GraphicsSceneMouseMove";
3101 case QEvent::GraphicsSceneMousePress:
3102 n = "GraphicsSceneMousePress";
3104 case QEvent::GraphicsSceneMouseRelease:
3105 n = "GraphicsSceneMouseRelease";
3107 case QEvent::GraphicsSceneMouseDoubleClick:
3108 n = "GraphicsSceneMouseDoubleClick";
3110 case QEvent::GraphicsSceneContextMenu:
3111 n = "GraphicsSceneContextMenu";
3113 case QEvent::GraphicsSceneHoverEnter:
3114 n = "GraphicsSceneHoverEnter";
3116 case QEvent::GraphicsSceneHoverMove:
3117 n = "GraphicsSceneHoverMove";
3119 case QEvent::GraphicsSceneHoverLeave:
3120 n = "GraphicsSceneHoverLeave";
3122 case QEvent::GraphicsSceneHelp:
3123 n = "GraphicsSceneHelp";
3125 case QEvent::GraphicsSceneDragEnter:
3126 n = "GraphicsSceneDragEnter";
3128 case QEvent::GraphicsSceneDragMove:
3129 n = "GraphicsSceneDragMove";
3131 case QEvent::GraphicsSceneDragLeave:
3132 n = "GraphicsSceneDragLeave";
3134 case QEvent::GraphicsSceneDrop:
3135 n = "GraphicsSceneDrop";
3137 case QEvent::GraphicsSceneWheel:
3138 n = "GraphicsSceneWheel";
3140 case QEvent::GraphicsSceneResize:
3141 n = "GraphicsSceneResize";
3143 case QEvent::GraphicsSceneMove:
3144 n = "GraphicsSceneMove";
3146 case QEvent::CursorChange:
3149 case QEvent::ToolTipChange:
3150 n = "ToolTipChange";
3152 case QEvent::StatusTip:
3155 case QEvent::WhatsThis:
3158 case QEvent::FontChange:
3164 case QEvent::KeyboardLayoutChange:
3165 n = "KeyboardLayoutChange";
3167 case QEvent::DynamicPropertyChange:
3168 n = "DynamicPropertyChange";
3170 case QEvent::GrabMouse:
3173 case QEvent::UngrabMouse:
3176 case QEvent::GrabKeyboard:
3179 case QEvent::UngrabKeyboard:
3180 n = "UngrabKeyboard";
3182 case QEvent::ChildAdded: n = n ? n : "ChildAdded";
3183 case QEvent::ChildPolished: n = n ? n : "ChildPolished";
3184 case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
3185 dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
3187 #ifndef QT_NO_GESTURES
3188 case QEvent::Gesture:
3193 dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
3197 dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
3203 \class QShortcutEvent
3204 \brief The QShortcutEvent class provides an event which is generated when
3205 the user presses a key combination.
3210 Normally you don't need to use this class directly; QShortcut
3211 provides a higher-level interface to handle shortcut keys.
3217 \fn const QKeySequence &QShortcutEvent::key() const
3219 Returns the key sequence that triggered the event.
3223 \fn int QShortcutEvent::shortcutId() const
3225 Returns the ID of the QShortcut object for which this event was
3232 \fn bool QShortcutEvent::isAmbiguous() const
3234 Returns true if the key sequence that triggered the event is
3237 \sa QShortcut::activatedAmbiguously()
3241 \class QWindowStateChangeEvent
3245 \brief The QWindowStateChangeEvent class provides the window state before a
3246 window state change.
3249 /*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
3251 Returns the state of the window before the change.
3256 QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
3257 : QEvent(WindowStateChange), ostate(s), m_override(isOverride)
3263 bool QWindowStateChangeEvent::isOverride() const
3270 QWindowStateChangeEvent::~QWindowStateChangeEvent()
3277 \brief The QTouchEvent class contains parameters that describe a touch event.
3283 \section1 Enabling Touch Events
3285 Touch events occur when pressing, releasing, or moving one or more touch points on a touch
3286 device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
3287 Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
3288 \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
3290 When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
3291 attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
3293 Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
3294 widget, and the widget will receive all updates for the touch point until it is released.
3295 Note that it is possible for a widget to receive events for numerous touch points, and that
3296 multiple widgets may be receiving touch events at the same time.
3298 \section1 Event Handling
3300 All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd or
3301 QEvent::TouchCancel. Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for
3302 widgets and QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
3304 Unlike widgets, QWindows receive touch events always, there is no need to opt in. When working
3305 directly with a QWindow, it is enough to reimplement QWindow::touchEvent().
3307 The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
3308 accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
3309 filtered by an event filter, then no further touch events are sent until the next
3312 Some systems may send an event of type QEvent::TouchCancel. Upon receiving this event
3313 applications are requested to ignore the entire active touch sequence. For example in a
3314 composited system the compositor may decide to treat certain gestures as system-wide
3315 gestures. Whenever such a decision is made (the gesture is recognized), the clients will be
3316 notified with a QEvent::TouchCancel event so they can update their state accordingly.
3318 The touchPoints() function returns a list of all touch points contained in the event. Note that
3319 this list may be empty, for example in case of a QEvent::TouchCancel event. Information about
3320 each touch point can be retrieved using the QTouchEvent::TouchPoint class. The
3321 Qt::TouchPointState enum describes the different states that a touch point may have.
3323 \note The list of touchPoints() will never be partial: A touch event will always contain a touch
3324 point for each existing physical touch contacts targetting the window or widget to which the
3325 event is sent. For instance, assuming that all touches target the same window or widget, an
3326 event with a condition of touchPoints().count()==2 is guaranteed to imply that the number of
3327 fingers touching the touchscreen or touchpad is exactly two.
3329 \section1 Event Delivery and Propagation
3331 By default, QGuiApplication translates the first touch point in a QTouchEvent into
3332 a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
3333 normally handle QTouchEvent. See below for information on some special considerations needed
3336 QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
3337 contains a special accept flag that indicates whether the receiver wants the event. By default,
3338 the event is accepted. You should call ignore() if the touch event is not handled by your
3339 widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
3340 accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
3341 QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
3342 propagation for QGraphicsItems).
3344 \section1 Touch Point Grouping
3346 As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
3347 same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
3348 widget, which could theoretically happen during propagation if, for example, the user touched 2
3349 separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
3351 To avoid this, Qt will group new touch points together using the following rules:
3355 \li When the first touch point is detected, the destination widget is determined firstly by the
3356 location on screen and secondly by the propagation rules.
3358 \li When additional touch points are detected, Qt first looks to see if there are any active
3359 touch points on any ancestor or descendent of the widget under the new touch point. If there
3360 are, the new touch point is grouped with the first, and the new touch point will be sent in a
3361 single QTouchEvent to the widget that handled the first touch point. (The widget under the new
3362 touch point will not receive an event).
3366 This makes it possible for sibling widgets to handle touch events independently while making
3367 sure that the sequence of QTouchEvents is always correct.
3369 \section1 Mouse Events and Touch Event synthesizing
3371 QTouchEvent delivery is independent from that of QMouseEvent. The application flags
3372 Qt::AA_SynthesizeTouchForUnhandledMouseEvents and Qt::AA_SynthesizeMouseForUnhandledTouchEvents
3373 can be used to enable or disable automatic synthesizing of touch events to mouse events and
3374 mouse events to touch events.
3380 \li As mentioned above, enabling touch events means multiple widgets can be receiving touch
3381 events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
3382 this gives you great flexibility in designing touch user interfaces. Be aware of the
3383 implications. For example, it is possible that the user is moving a QSlider with one finger and
3384 pressing a QPushButton with another. The signals emitted by these widgets will be
3387 \li Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
3388 QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
3389 recipients, recursion may cause problems, including but not limited to lost events
3390 and unexpected infinite recursion.
3392 \li QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
3393 \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
3394 undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
3399 \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
3400 QGraphicsItem::acceptTouchEvents()
3403 /*! \enum Qt::TouchPointState
3406 This enum represents the state of a touch point at the time the
3407 QTouchEvent occurred.
3409 \value TouchPointPressed The touch point is now pressed.
3410 \value TouchPointMoved The touch point moved.
3411 \value TouchPointStationary The touch point did not move.
3412 \value TouchPointReleased The touch point was released.
3415 /*! \enum QTouchEvent::DeviceType
3417 This enum represents the type of device that generated a QTouchEvent.
3419 This enum has been deprecated. Use QTouchDevice::DeviceType instead.
3421 \sa QTouchDevice::DeviceType, QTouchDevice::type(), QTouchEvent::device()
3425 Constructs a QTouchEvent with the given \a eventType, \a deviceType, \a
3426 touchPoints and \a device. The \a touchPointStates and \a modifiers
3427 are the current touch point states and keyboard modifiers at the time of
3430 QTouchEvent::QTouchEvent(QEvent::Type eventType,
3431 QTouchDevice *device,
3432 Qt::KeyboardModifiers modifiers,
3433 Qt::TouchPointStates touchPointStates,
3434 const QList<QTouchEvent::TouchPoint> &touchPoints)
3435 : QInputEvent(eventType, modifiers),
3439 _touchPointStates(touchPointStates),
3440 _touchPoints(touchPoints)
3444 Destroys the QTouchEvent.
3446 QTouchEvent::~QTouchEvent()
3449 /*! \fn QWindow *QTouchEvent::window() const
3451 Returns the window on which the event occurred. Useful for doing
3452 global-local mapping on data like rawScreenPositions() which,
3453 for performance reasons, only stores the global positions in the
3457 /*! \fn QObject *QTouchEvent::target() const
3459 Returns the target object within the window on which the event occurred.
3460 This is typically a QWidget or a QQuickItem. May be 0 when no specific target is available.
3463 /*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
3465 Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
3467 This function has been deprecated. Use QTouchDevice::type() instead.
3469 \sa QTouchDevice::type(), QTouchEvent::device()
3472 /*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
3474 Returns a bitwise OR of all the touch point states for this event.
3477 /*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
3479 Returns the list of touch points contained in the touch event.
3482 /*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
3484 Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
3487 /*! \fn QTouchDevice* QTouchEvent::device() const
3489 Returns the touch device from which this touch event originates.
3492 /*! \fn void QTouchEvent::setWindow(QWindow *window)
3496 Sets the window for this event.
3499 /*! \fn void QTouchEvent::setTarget(QObject *target)
3503 Sets the target within the window (typically a widget) for this event.
3506 /*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
3510 Sets a bitwise OR of all the touch point states for this event.
3513 /*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
3517 Sets the list of touch points for this event.
3520 /*! \fn void QTouchEvent::setDeviceType(DeviceType deviceType)
3524 Sets the device type to \a deviceType, which is of type \l {QTouchEvent::DeviceType}
3528 /*! \fn void QTouchEvent::setTouchDevice(QTouchDevice *device)
3532 Sets the touch event's device to the given one.
3535 /*! \class QTouchEvent::TouchPoint
3536 \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
3541 /*! \enum QTouchEvent::TouchPoint::InfoFlags
3543 The values of this enum describe additional information about a touch point.
3545 \value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger.
3550 Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
3552 QTouchEvent::TouchPoint::TouchPoint(int id)
3553 : d(new QTouchEventTouchPointPrivate(id))
3558 Constructs a copy of \a other.
3560 QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
3568 Destroys the QTouchEvent::TouchPoint.
3570 QTouchEvent::TouchPoint::~TouchPoint()
3572 if (d && !d->ref.deref())
3577 Returns the id number of this touch point.
3579 Do not assume that id numbers start at zero or that they are sequential.
3580 Such an assumption is often false due to the way the underlying drivers work.
3582 int QTouchEvent::TouchPoint::id() const
3588 Returns the current state of this touch point.
3590 Qt::TouchPointState QTouchEvent::TouchPoint::state() const
3592 return Qt::TouchPointState(int(d->state));
3596 Returns the position of this touch point, relative to the widget
3597 or QGraphicsItem that received the event.
3599 \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
3601 QPointF QTouchEvent::TouchPoint::pos() const
3603 return d->rect.center();
3607 Returns the scene position of this touch point.
3609 The scene position is the position in QGraphicsScene coordinates
3610 if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3611 reimplementation, and identical to the screen position for
3614 \sa startScenePos(), lastScenePos(), pos()
3616 QPointF QTouchEvent::TouchPoint::scenePos() const
3618 return d->sceneRect.center();
3622 Returns the screen position of this touch point.
3624 \sa startScreenPos(), lastScreenPos(), pos()
3626 QPointF QTouchEvent::TouchPoint::screenPos() const
3628 return d->screenRect.center();
3632 Returns the normalized position of this touch point.
3634 The coordinates are normalized to the size of the touch device,
3635 i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3637 \sa startNormalizedPos(), lastNormalizedPos(), pos()
3639 QPointF QTouchEvent::TouchPoint::normalizedPos() const
3641 return d->normalizedPos;
3645 Returns the starting position of this touch point, relative to the
3646 widget or QGraphicsItem that received the event.
3648 \sa pos(), lastPos()
3650 QPointF QTouchEvent::TouchPoint::startPos() const
3656 Returns the starting scene position of this touch point.
3658 The scene position is the position in QGraphicsScene coordinates
3659 if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3660 reimplementation, and identical to the screen position for
3663 \sa scenePos(), lastScenePos()
3665 QPointF QTouchEvent::TouchPoint::startScenePos() const
3667 return d->startScenePos;
3671 Returns the starting screen position of this touch point.
3673 \sa screenPos(), lastScreenPos()
3675 QPointF QTouchEvent::TouchPoint::startScreenPos() const
3677 return d->startScreenPos;
3681 Returns the normalized starting position of this touch point.
3683 The coordinates are normalized to the size of the touch device,
3684 i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3686 \sa normalizedPos(), lastNormalizedPos()
3688 QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
3690 return d->startNormalizedPos;
3694 Returns the position of this touch point from the previous touch
3695 event, relative to the widget or QGraphicsItem that received the event.
3697 \sa pos(), startPos()
3699 QPointF QTouchEvent::TouchPoint::lastPos() const
3705 Returns the scene position of this touch point from the previous
3708 The scene position is the position in QGraphicsScene coordinates
3709 if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3710 reimplementation, and identical to the screen position for
3713 \sa scenePos(), startScenePos()
3715 QPointF QTouchEvent::TouchPoint::lastScenePos() const
3717 return d->lastScenePos;
3721 Returns the screen position of this touch point from the previous
3724 \sa screenPos(), startScreenPos()
3726 QPointF QTouchEvent::TouchPoint::lastScreenPos() const
3728 return d->lastScreenPos;
3732 Returns the normalized position of this touch point from the
3733 previous touch event.
3735 The coordinates are normalized to the size of the touch device,
3736 i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3738 \sa normalizedPos(), startNormalizedPos()
3740 QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
3742 return d->lastNormalizedPos;
3746 Returns the rect for this touch point, relative to the widget
3747 or QGraphicsItem that received the event. The rect is centered
3748 around the point returned by pos().
3750 \note This function returns an empty rect if the device does not report touch point sizes.
3752 QRectF QTouchEvent::TouchPoint::rect() const
3758 Returns the rect for this touch point in scene coordinates.
3760 \note This function returns an empty rect if the device does not report touch point sizes.
3762 \sa scenePos(), rect()
3764 QRectF QTouchEvent::TouchPoint::sceneRect() const
3766 return d->sceneRect;
3770 Returns the rect for this touch point in screen coordinates.
3772 \note This function returns an empty rect if the device does not report touch point sizes.
3774 \sa screenPos(), rect()
3776 QRectF QTouchEvent::TouchPoint::screenRect() const
3778 return d->screenRect;
3782 Returns the pressure of this touch point. The return value is in
3783 the range 0.0 to 1.0.
3785 qreal QTouchEvent::TouchPoint::pressure() const
3791 Returns a velocity vector for this touch point.
3792 The vector is in the screen's coordinate system, using pixels per seconds for the magnitude.
3794 \note The returned vector is only valid if the touch device's capabilities include QTouchDevice::Velocity.
3796 \sa QTouchDevice::capabilities(), device()
3798 QVector2D QTouchEvent::TouchPoint::velocity() const
3804 Returns additional information about the touch point.
3806 \sa QTouchEvent::TouchPoint::InfoFlags
3808 QTouchEvent::TouchPoint::InfoFlags QTouchEvent::TouchPoint::flags() const
3815 Returns the raw, unfiltered positions for the touch point. The positions are in native screen coordinates.
3816 To get local coordinates you can use mapFromGlobal() of the QWindow returned by QTouchEvent::window().
3818 \note Returns an empty vector if the touch device's capabilities do not include QTouchDevice::RawPositions.
3820 \note Native screen coordinates refer to the native orientation of the screen which, in case of
3821 mobile devices, is typically portrait. This means that on systems capable of screen orientation
3822 changes the positions in this list will not reflect the current orientation (unlike pos(),
3823 screenPos(), etc.) and will always be reported in the native orientation.
3825 \sa QTouchDevice::capabilities(), device(), window()
3827 QVector<QPointF> QTouchEvent::TouchPoint::rawScreenPositions() const
3829 return d->rawScreenPositions;
3833 void QTouchEvent::TouchPoint::setId(int id)
3835 if (d->ref.load() != 1)
3841 void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
3843 if (d->ref.load() != 1)
3849 void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
3851 if (d->ref.load() != 1)
3853 d->rect.moveCenter(pos);
3857 void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
3859 if (d->ref.load() != 1)
3861 d->sceneRect.moveCenter(scenePos);
3865 void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
3867 if (d->ref.load() != 1)
3869 d->screenRect.moveCenter(screenPos);
3873 void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
3875 if (d->ref.load() != 1)
3877 d->normalizedPos = normalizedPos;
3881 void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
3883 if (d->ref.load() != 1)
3885 d->startPos = startPos;
3889 void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
3891 if (d->ref.load() != 1)
3893 d->startScenePos = startScenePos;
3897 void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
3899 if (d->ref.load() != 1)
3901 d->startScreenPos = startScreenPos;
3905 void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
3907 if (d->ref.load() != 1)
3909 d->startNormalizedPos = startNormalizedPos;
3913 void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
3915 if (d->ref.load() != 1)
3917 d->lastPos = lastPos;
3921 void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
3923 if (d->ref.load() != 1)
3925 d->lastScenePos = lastScenePos;
3929 void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
3931 if (d->ref.load() != 1)
3933 d->lastScreenPos = lastScreenPos;
3937 void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
3939 if (d->ref.load() != 1)
3941 d->lastNormalizedPos = lastNormalizedPos;
3945 void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
3947 if (d->ref.load() != 1)
3953 void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
3955 if (d->ref.load() != 1)
3957 d->sceneRect = sceneRect;
3961 void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
3963 if (d->ref.load() != 1)
3965 d->screenRect = screenRect;
3969 void QTouchEvent::TouchPoint::setPressure(qreal pressure)
3971 if (d->ref.load() != 1)
3973 d->pressure = pressure;
3977 void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v)
3979 if (d->ref.load() != 1)
3985 void QTouchEvent::TouchPoint::setRawScreenPositions(const QVector<QPointF> &positions)
3987 if (d->ref.load() != 1)
3989 d->rawScreenPositions = positions;
3993 void QTouchEvent::TouchPoint::setFlags(InfoFlags flags)
3995 if (d->ref.load() != 1)
4001 \fn QTouchEvent::TouchPoint &QTouchEvent::TouchPoint::operator=(const QTouchEvent::TouchPoint &other)
4006 \fn void QTouchEvent::TouchPoint::swap(TouchPoint &other);
4011 \class QScrollPrepareEvent
4016 \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
4018 The scroll prepare event is send before scrolling (usually by QScroller) is started.
4019 The object receiving this event should set viewportSize, maxContentPos and contentPos.
4020 It also should accept this event to indicate that scrolling should be started.
4022 It is not guaranteed that a QScrollEvent will be send after an acceepted
4023 QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
4025 \sa QScrollEvent, QScroller
4029 Creates new QScrollPrepareEvent
4030 The \a startPos is the position of a touch or mouse event that started the scrolling.
4032 QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
4033 : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos)
4038 Destroys QScrollEvent.
4040 QScrollPrepareEvent::~QScrollPrepareEvent()
4045 Returns the position of the touch or mouse event that started the scrolling.
4047 QPointF QScrollPrepareEvent::startPos() const
4053 Returns size of the area that is to be scrolled as set by setViewportSize
4055 \sa setViewportSize()
4057 QSizeF QScrollPrepareEvent::viewportSize() const
4059 return m_viewportSize;
4063 Returns the range of coordinates for the content as set by setContentPosRange().
4065 QRectF QScrollPrepareEvent::contentPosRange() const
4067 return m_contentPosRange;
4071 Returns the current position of the content as set by setContentPos.
4073 QPointF QScrollPrepareEvent::contentPos() const
4075 return m_contentPos;
4080 Sets the size of the area that is to be scrolled to \a size.
4084 void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
4086 m_viewportSize = size;
4090 Sets the range of content coordinates to \a rect.
4092 \sa contentPosRange()
4094 void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
4096 m_contentPosRange = rect;
4100 Sets the current content position to \a pos.
4104 void QScrollPrepareEvent::setContentPos(const QPointF &pos)
4116 \brief The QScrollEvent class is send when scrolling.
4118 The scroll event is send to indicate that the receiver should be scrolled.
4119 Usually the receiver should be something visual like QWidget or QGraphicsObject.
4121 Some care should be taken that no conflicting QScrollEvents are sent from two
4122 sources. Using QScroller::scrollTo is save however.
4124 \sa QScrollPrepareEvent, QScroller
4128 \enum QScrollEvent::ScrollState
4130 This enum describes the states a scroll event can have.
4132 \value ScrollStarted Set for the first scroll event of a scroll activity.
4134 \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
4136 \value ScrollFinished Set for the last scroll event of a scroll activity.
4138 \sa QScrollEvent::scrollState()
4142 Creates a new QScrollEvent
4143 \a contentPos is the new content position, \a overshootDistance is the
4144 new overshoot distance while \a scrollState indicates if this scroll
4145 event is the first one, the last one or some event in between.
4147 QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
4148 : QEvent(QEvent::Scroll), m_contentPos(contentPos), m_overshoot(overshootDistance), m_state(scrollState)
4153 Destroys QScrollEvent.
4155 QScrollEvent::~QScrollEvent()
4160 Returns the new scroll position.
4162 QPointF QScrollEvent::contentPos() const
4164 return m_contentPos;
4168 Returns the new overshoot distance.
4169 See QScroller for an explanation of the term overshoot.
4173 QPointF QScrollEvent::overshootDistance() const
4179 Returns the current scroll state as a combination of ScrollStateFlag values.
4180 ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
4181 Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
4182 All other scroll events in between will have their state set to ScrollUpdated.
4184 A widget could for example revert selections when scrolling is started and stopped.
4186 QScrollEvent::ScrollState QScrollEvent::scrollState() const
4192 Creates a new QScreenOrientationChangeEvent
4193 \a orientation is the new orientation of the screen.
4195 QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation)
4196 : QEvent(QEvent::OrientationChange), m_screen(screen), m_orientation(screenOrientation)
4201 Destroys QScreenOrientationChangeEvent.
4203 QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
4208 Returns the screen whose orientation changed.
4210 QScreen *QScreenOrientationChangeEvent::screen() const
4216 Returns the orientation of the screen.
4218 Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
4220 return m_orientation;