1 /****************************************************************************
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
6 ** This file is part of the QtGui module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
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"
62 \brief The QEnterEvent class contains parameters that describe an enter event.
64 Enter events occur when the mouse cursor enters a window or a widget.
70 Constructs an enter event object.
72 The points \a localPos, \a windowPos and \a screenPos specify the
73 mouse cursor's position relative to the receiving widget or item,
74 window, and screen, respectively.
77 QEnterEvent::QEnterEvent(const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos)
78 : QEvent(QEvent::Enter)
88 QEnterEvent::~QEnterEvent()
97 \brief The QInputEvent class is the base class for events that
104 QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
105 : QEvent(type), modState(modifiers), ts(0)
111 QInputEvent::~QInputEvent()
116 \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
118 Returns the keyboard modifier flags that existed immediately
119 before the event occurred.
121 \sa QApplication::keyboardModifiers()
124 /*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
128 Sets the keyboard modifiers flags for this event.
132 \fn ulong QInputEvent::timestamp() const
134 Returns the window system's timestamp for this event.
137 /*! \fn void QInputEvent::setTimestamp(ulong atimestamp)
141 Sets the timestamp for this event.
148 \brief The QMouseEvent class contains parameters that describe a mouse event.
150 Mouse events occur when a mouse button is pressed or released
151 inside a widget, or when the mouse cursor is moved.
153 Mouse move events will occur only when a mouse button is pressed
154 down, unless mouse tracking has been enabled with
155 QWidget::setMouseTracking().
157 Qt automatically grabs the mouse when a mouse button is pressed
158 inside a widget; the widget will continue to receive mouse events
159 until the last mouse button is released.
161 A mouse event contains a special accept flag that indicates
162 whether the receiver wants the event. You should call ignore() if
163 the mouse event is not handled by your widget. A mouse event is
164 propagated up the parent widget chain until a widget accepts it
165 with accept(), or an event filter consumes it.
167 \note If a mouse event is propagated to a \l{QWidget}{widget} for
168 which Qt::WA_NoMousePropagation has been set, that mouse event
169 will not be propagated further up the parent widget chain.
171 The state of the keyboard modifier keys can be found by calling the
172 \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
175 The functions pos(), x(), and y() give the cursor position
176 relative to the widget that receives the mouse event. If you
177 move the widget as a result of the mouse event, use the global
178 position returned by globalPos() to avoid a shaking motion.
180 The QWidget::setEnabled() function can be used to enable or
181 disable mouse and keyboard events for a widget.
183 Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
184 QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
185 and QWidget::mouseMoveEvent() to receive mouse events in your own
188 \sa QWidget::setMouseTracking(), QWidget::grabMouse(),
193 Constructs a mouse event object.
195 The \a type parameter must be one of QEvent::MouseButtonPress,
196 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
197 or QEvent::MouseMove.
199 The \a localPos is the mouse cursor's position relative to the
200 receiving widget or item. The window position is set to the same value
202 The \a button that caused the event is given as a value from
203 the Qt::MouseButton enum. If the event \a type is
204 \l MouseMove, the appropriate button for this event is Qt::NoButton.
205 The mouse and keyboard states at the time of the event are specified by
206 \a buttons and \a modifiers.
208 The screenPos() is initialized to QCursor::pos(), which may not
209 be appropriate. Use the other constructor to specify the global
212 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button,
213 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
214 : QInputEvent(type, modifiers), l(localPos), w(localPos), b(button), mouseState(buttons), caps(0)
221 Constructs a mouse event object.
223 The \a type parameter must be QEvent::MouseButtonPress,
224 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
225 or QEvent::MouseMove.
227 The \a localPos is the mouse cursor's position relative to the
228 receiving widget or item. The cursor's position in screen coordinates is
229 specified by \a screenPos. The window position is set to the same value
230 as \a localPos. The \a button that caused the event is
231 given as a value from the \l Qt::MouseButton enum. If the event \a
232 type is \l MouseMove, the appropriate button for this event is
233 Qt::NoButton. \a buttons is the state of all buttons at the
234 time of the event, \a modifiers the state of all keyboard
238 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &screenPos,
239 Qt::MouseButton button, Qt::MouseButtons buttons,
240 Qt::KeyboardModifiers modifiers)
241 : QInputEvent(type, modifiers), l(localPos), w(localPos), s(screenPos), b(button), mouseState(buttons), caps(0)
245 Constructs a mouse event object.
247 The \a type parameter must be QEvent::MouseButtonPress,
248 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
249 or QEvent::MouseMove.
251 The points \a localPos, \a windowPos and \a screenPos specify the
252 mouse cursor's position relative to the receiving widget or item,
253 window, and screen, respectively.
255 The \a button that caused the event is
256 given as a value from the \l Qt::MouseButton enum. If the event \a
257 type is \l MouseMove, the appropriate button for this event is
258 Qt::NoButton. \a buttons is the state of all buttons at the
259 time of the event, \a modifiers the state of all keyboard
263 QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &windowPos, const QPointF &screenPos,
264 Qt::MouseButton button, Qt::MouseButtons buttons,
265 Qt::KeyboardModifiers modifiers)
266 : QInputEvent(type, modifiers), l(localPos), w(windowPos), s(screenPos), b(button), mouseState(buttons), caps(0)
272 QMouseEvent::~QMouseEvent()
278 \fn QPointF QMouseEvent::localPos() const
282 Returns the position of the mouse cursor as a QPointF, relative to the
283 widget or item that received the event.
285 If you move the widget as a result of the mouse event, use the
286 screen position returned by screenPos() to avoid a shaking
289 \sa x(), y(), windowPos(), screenPos()
293 \fn QPointF QMouseEvent::windowPos() const
297 Returns the position of the mouse cursor as a QPointF, relative to the
298 window that received the event.
300 If you move the widget as a result of the mouse event, use the
301 global position returned by globalPos() to avoid a shaking
304 \sa x(), y(), pos(), localPos(), screenPos()
308 \fn QPointF QMouseEvent::screenPos() const
312 Returns the position of the mouse cursor as a QPointF, relative to the
313 screen that received the event.
315 \sa x(), y(), pos(), localPos(), screenPos()
319 \fn QPoint QMouseEvent::pos() const
321 Returns the position of the mouse cursor, relative to the widget
322 that received the event.
324 If you move the widget as a result of the mouse event, use the
325 global position returned by globalPos() to avoid a shaking
328 \sa x(), y(), globalPos()
332 \fn QPoint QMouseEvent::globalPos() const
334 Returns the global position of the mouse cursor \e{at the time
335 of the event}. This is important on asynchronous window systems
336 like X11. Whenever you move your widgets around in response to
337 mouse events, globalPos() may differ a lot from the current
338 pointer position QCursor::pos(), and from
339 QWidget::mapToGlobal(pos()).
341 \sa globalX(), globalY()
345 \fn int QMouseEvent::x() const
347 Returns the x position of the mouse cursor, relative to the
348 widget that received the event.
354 \fn int QMouseEvent::y() const
356 Returns the y position of the mouse cursor, relative to the
357 widget that received the event.
363 \fn int QMouseEvent::globalX() const
365 Returns the global x position of the mouse cursor at the time of
368 \sa globalY(), globalPos()
372 \fn int QMouseEvent::globalY() const
374 Returns the global y position of the mouse cursor at the time of
377 \sa globalX(), globalPos()
381 \fn Qt::MouseButton QMouseEvent::button() const
383 Returns the button that caused the event.
385 Note that the returned value is always Qt::NoButton for mouse
388 \sa buttons(), Qt::MouseButton
392 \fn Qt::MouseButton QMouseEvent::buttons() const
394 Returns the button state when the event was generated. The button
395 state is a combination of Qt::LeftButton, Qt::RightButton,
396 Qt::MidButton using the OR operator. For mouse move events,
397 this is all buttons that are pressed down. For mouse press and
398 double click events this includes the button that caused the
399 event. For mouse release events this excludes the button that
402 \sa button(), Qt::MouseButton
406 \fn QPointF QMouseEvent::posF() const
409 Use localPos() instead.
416 \brief The QHoverEvent class contains parameters that describe a mouse event.
418 Mouse events occur when a mouse cursor is moved into, out of, or within a
419 widget, and if the widget has the Qt::WA_Hover attribute.
421 The function pos() gives the current cursor position, while oldPos() gives
422 the old mouse position.
424 There are a few similarities between the events QEvent::HoverEnter
425 and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
426 However, they are slightly different because we do an update() in the event
427 handler of HoverEnter and HoverLeave.
429 QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
430 consider a top-level window A containing a child B which in turn contains a
431 child C (all with mouse tracking enabled):
433 \image hoverevents.png
435 Now, if you move the cursor from the top to the bottom in the middle of A,
436 you will get the following QEvent::MouseMove events:
444 You will get the same events for QEvent::HoverMove, except that the event
445 always propagates to the top-level regardless whether the event is accepted
446 or not. It will only stop propagating with the Qt::WA_NoMousePropagation
449 In this case the events will occur in the following way:
453 \li A::HoverMove, B::HoverMove
454 \li A::HoverMove, B::HoverMove, C::HoverMove
460 \fn QPoint QHoverEvent::pos() const
462 Returns the position of the mouse cursor, relative to the widget
463 that received the event.
465 On QEvent::HoverLeave events, this position will always be
472 \fn QPoint QHoverEvent::oldPos() const
474 Returns the previous position of the mouse cursor, relative to the widget
475 that received the event. If there is no previous position, oldPos() will
476 return the same position as pos().
478 On QEvent::HoverEnter events, this position will always be
485 \fn const QPointF &QHoverEvent::posF() const
487 Returns the position of the mouse cursor, relative to the widget
488 that received the event.
490 On QEvent::HoverLeave events, this position will always be
497 \fn const QPointF &QHoverEvent::oldPosF() const
499 Returns the previous position of the mouse cursor, relative to the widget
500 that received the event. If there is no previous position, oldPosF() will
501 return the same position as posF().
503 On QEvent::HoverEnter events, this position will always be
510 Constructs a hover event object.
512 The \a type parameter must be QEvent::HoverEnter,
513 QEvent::HoverLeave, or QEvent::HoverMove.
515 The \a pos is the current mouse cursor's position relative to the
516 receiving widget, while \a oldPos is its previous such position.
517 \a modifiers hold the state of all keyboard modifiers at the time
520 QHoverEvent::QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers)
521 : QInputEvent(type, modifiers), p(pos), op(oldPos)
528 QHoverEvent::~QHoverEvent()
535 \brief The QWheelEvent class contains parameters that describe a wheel event.
540 Wheel events are sent to the widget under the mouse cursor, but
541 if that widget does not handle the event they are sent to the
542 focus widget. Wheel events are generated for both mouse wheels
543 and trackpad scroll gestures. There are two ways to read the
544 wheel event delta: angleDelta() returns the delta in wheel
545 degrees. This value is always provided. pixelDelta() returns
546 the delta in screen pixels and is available on platforms that
547 have high-resolution trackpads, such as Mac OS X.
549 The functions pos() and globalPos() return the mouse cursor's
550 location at the time of the event.
552 A wheel event contains a special accept flag that indicates
553 whether the receiver wants the event. You should call ignore() if
554 you do not handle the wheel event; this ensures that it will be
555 sent to the parent widget.
557 The QWidget::setEnabled() function can be used to enable or
558 disable mouse and keyboard events for a widget.
560 The event handler QWidget::wheelEvent() receives wheel events.
562 \sa QMouseEvent, QWidget::grabMouse()
566 \fn Qt::MouseButtons QWheelEvent::buttons() const
568 Returns the mouse state when the event occurred.
572 \fn Qt::Orientation QWheelEvent::orientation() const
575 Returns the wheel's orientation.
577 Use angleDelta() instead.
582 Constructs a wheel event object.
584 Use the constructor taking \e angleDelta and \e pixelDelta QPoints instead.
586 The position, \a pos, is the location of the mouse cursor within
587 the widget. The globalPos() is initialized to QCursor::pos()
588 which is usually, but not always, correct.
589 Use the other constructor if you need to specify the global
592 The \a buttons describe the state of the mouse buttons at the time
593 of the event, \a delta contains the rotation distance,
594 \a modifiers holds the keyboard modifier flags at the time of the
595 event, and \a orient holds the wheel's orientation.
597 \sa pos(), pixelDelta(), angleDelta(), state()
599 #ifndef QT_NO_WHEELEVENT
600 QWheelEvent::QWheelEvent(const QPointF &pos, int delta,
601 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
602 Qt::Orientation orient)
603 : QInputEvent(Wheel, modifiers), p(pos), qt4D(delta), qt4O(orient), mouseState(buttons)
611 QWheelEvent::~QWheelEvent()
617 Constructs a wheel event object.
619 Use the constructor taking \e angleDelta and \e pixelDelta QPoints instead.
621 The \a pos provides the location of the mouse cursor
622 within the widget. The position in global coordinates is specified
623 by \a globalPos. \a delta contains the rotation distance, \a modifiers
624 holds the keyboard modifier flags at the time of the event, and
625 \a orient holds the wheel's orientation.
628 \sa pos(), pixelDelta(), angleDelta(), state()
630 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos, int delta,
631 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
632 Qt::Orientation orient)
633 : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), qt4D(delta), qt4O(orient), mouseState(buttons)
637 Constructs a wheel event object.
639 The \a pos provides the location of the mouse cursor
640 within the window. The position in global coordinates is specified
643 \a pixelDelta contains the scrolling distance in pixels on screen, while
644 \a angleDelta contains the wheel rotation distance. \a pixelDelta is
645 optional and can be null.
647 The mouse and keyboard states at the time of the event are specified by
648 \a buttons and \a modifiers.
650 For backwards compatibility, the event can also hold monodirectional wheel
651 event data: \a qt4Delta specifies the rotation, and \a qt4Orientation the
654 \sa posF(), globalPosF(), angleDelta(), pixelDelta()
657 QWheelEvent::QWheelEvent(const QPointF &pos, const QPointF& globalPos,
658 QPoint pixelDelta, QPoint angleDelta, int qt4Delta, Qt::Orientation qt4Orientation,
659 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
660 : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), pixelD(pixelDelta),
661 angleD(angleDelta), qt4D(qt4Delta), qt4O(qt4Orientation), mouseState(buttons)
665 #endif // QT_NO_WHEELEVENT
668 \fn QPoint QWheelEvent::pixelDelta() const
670 Returns the scrolling distance in pixels on screen. This value is
671 provided on platforms that support high-resolution pixel-based
672 delta values, such as Mac OS X. The value should be used directly
673 to scroll content on screen.
677 \snippet code/src_gui_kernel_qevent.cpp 0
681 \fn QPoint QWheelEvent::angleDelta() const
683 Returns the distance that the wheel is rotated, in eighths of a
684 degree. A positive value indicates that the wheel was rotated
685 forwards away from the user; a negative value indicates that the
686 wheel was rotated backwards toward the user.
688 Most mouse types work in steps of 15 degrees, in which case the
689 delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
691 However, some mice have finer-resolution wheels and send delta values
692 that are less than 120 units (less than 15 degrees). To support this
693 possibility, you can either cumulatively add the delta values from events
694 until the value of 120 is reached, then scroll the widget, or you can
695 partially scroll the widget in response to each wheel event.
699 \snippet code/src_gui_kernel_qevent.cpp 0
703 \fn int QWheelEvent::delta() const
706 This function has been deprecated, use pixelDelta() or angleDelta() instead.
710 \fn QPoint QWheelEvent::pos() const
712 Returns the position of the mouse cursor relative to the widget
713 that received the event.
715 If you move your widgets around in response to mouse events,
716 use globalPos() instead of this function.
718 \sa x(), y(), globalPos()
722 \fn int QWheelEvent::x() const
724 Returns the x position of the mouse cursor, relative to the
725 widget that received the event.
731 \fn int QWheelEvent::y() const
733 Returns the y position of the mouse cursor, relative to the
734 widget that received the event.
741 \fn QPoint QWheelEvent::globalPos() const
743 Returns the global position of the mouse pointer \e{at the time
744 of the event}. This is important on asynchronous window systems
745 such as X11; whenever you move your widgets around in response to
746 mouse events, globalPos() can differ a lot from the current
747 cursor position returned by QCursor::pos().
749 \sa globalX(), globalY()
753 \fn int QWheelEvent::globalX() const
755 Returns the global x position of the mouse cursor at the time of
758 \sa globalY(), globalPos()
762 \fn int QWheelEvent::globalY() const
764 Returns the global y position of the mouse cursor at the time of
767 \sa globalX(), globalPos()
771 \fn const QPointF &QWheelEvent::posF() const
773 Returns the position of the mouse cursor relative to the widget
774 that received the event.
776 If you move your widgets around in response to mouse events,
777 use globalPosF() instead of this function.
783 \fn const QPointF &QWheelEvent::globalPosF() const
785 Returns the global position of the mouse pointer \e{at the time
786 of the event}. This is important on asynchronous window systems
787 such as X11; whenever you move your widgets around in response to
788 mouse events, globalPosF() can differ a lot from the current
789 cursor position returned by QCursor::pos().
797 \brief The QKeyEvent class describes a key event.
801 Key events are sent to the widget with keyboard input focus
802 when keys are pressed or released.
804 A key event contains a special accept flag that indicates whether
805 the receiver will handle the key event. You should call ignore()
806 if the key press or release event is not handled by your widget.
807 A key event is propagated up the parent widget chain until a
808 widget accepts it with accept() or an event filter consumes it.
809 Key events for multimedia keys are ignored by default. You should
810 call accept() if your widget handles those events.
812 The QWidget::setEnable() function can be used to enable or disable
813 mouse and keyboard events for a widget.
815 The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
816 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
819 \sa QFocusEvent, QWidget::grabKeyboard()
823 Constructs a key event object.
825 The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
826 or QEvent::ShortcutOverride.
828 Int \a key is the code for the Qt::Key that the event loop should listen
829 for. If \a key is 0, the event is not a result of a known key; for
830 example, it may be the result of a compose sequence or keyboard macro.
831 The \a modifiers holds the keyboard modifiers, and the given \a text
832 is the Unicode text that the key generated. If \a autorep is true,
833 isAutoRepeat() will be true. \a count is the number of keys involved
836 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
837 bool autorep, ushort count)
838 : QInputEvent(type, modifiers), txt(text), k(key),
839 nScanCode(0), nVirtualKey(0), nModifiers(0),
840 c(count), autor(autorep)
845 Constructs a key event object.
847 The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
848 or QEvent::ShortcutOverride.
850 Int \a key is the code for the Qt::Key that the event loop should listen
851 for. If \a key is 0, the event is not a result of a known key; for
852 example, it may be the result of a compose sequence or keyboard macro.
853 The \a modifiers holds the keyboard modifiers, and the given \a text
854 is the Unicode text that the key generated. If \a autorep is true,
855 isAutoRepeat() will be true. \a count is the number of keys involved
858 In addition to the normal key event data, also contains \a nativeScanCode,
859 \a nativeVirtualKey and \a nativeModifiers. This extra data is used by the
860 shortcut system, to determine which shortcuts to trigger.
862 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
863 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers,
864 const QString &text, bool autorep, ushort count)
865 : QInputEvent(type, modifiers), txt(text), k(key),
866 nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers),
867 c(count), autor(autorep)
875 QKeyEvent::~QKeyEvent()
880 \fn QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString& text, bool autorep, ushort count)
885 \fn bool QKeyEvent::hasExtendedInfo() const
890 \fn quint32 QKeyEvent::nativeScanCode() const
893 Returns the native scan code of the key event. If the key event
894 does not contain this data 0 is returned.
896 Note: The native scan code may be 0, even if the key event contains
897 extended information.
899 Note: On Mac OS/X, this function is not useful, because there is no
900 way to get the scan code from Carbon or Cocoa. The function always
901 returns 1 (or 0 in the case explained above).
905 \fn quint32 QKeyEvent::nativeVirtualKey() const
908 Returns the native virtual key, or key sym of the key event.
909 If the key event does not contain this data 0 is returned.
911 Note: The native virtual key may be 0, even if the key event contains extended information.
915 \fn quint32 QKeyEvent::nativeModifiers() const
918 Returns the native modifiers of a key event.
919 If the key event does not contain this data 0 is returned.
921 Note: The native modifiers may be 0, even if the key event contains extended information.
925 \fn int QKeyEvent::key() const
927 Returns the code of the key that was pressed or released.
929 See \l Qt::Key for the list of keyboard codes. These codes are
930 independent of the underlying window system. Note that this
931 function does not distinguish between capital and non-capital
932 letters, use the text() function (returning the Unicode text the
933 key generated) for this purpose.
935 A value of either 0 or Qt::Key_unknown means that the event is not
936 the result of a known key; for example, it may be the result of
937 a compose sequence, a keyboard macro, or due to key event
940 \sa Qt::WA_KeyCompression
944 \fn QString QKeyEvent::text() const
946 Returns the Unicode text that this key generated. The text
947 returned can be an empty string in cases
948 where modifier keys, such as Shift, Control, Alt, and Meta,
949 are being pressed or released. In such cases key() will contain
952 \sa Qt::WA_KeyCompression
956 Returns the keyboard modifier flags that existed immediately
957 after the event occurred.
959 \warning This function cannot always be trusted. The user can
960 confuse it by pressing both \uicontrol{Shift} keys simultaneously and
961 releasing one of them, for example.
963 \sa QApplication::keyboardModifiers()
965 //###### We must check with XGetModifierMapping
966 Qt::KeyboardModifiers QKeyEvent::modifiers() const
968 if (key() == Qt::Key_Shift)
969 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
970 if (key() == Qt::Key_Control)
971 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
972 if (key() == Qt::Key_Alt)
973 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
974 if (key() == Qt::Key_Meta)
975 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
976 return QInputEvent::modifiers();
979 #ifndef QT_NO_SHORTCUT
981 \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
984 Returns true if the key event matches the given standard \a key;
985 otherwise returns false.
987 bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
989 uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
990 const uint platform = QKeySequencePrivate::currentKeyPlatforms();
993 uint N = QKeySequencePrivate::numberOfKeyBindings;
997 while (first <= last) {
998 int mid = (first + last) / 2;
999 QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
1001 if (searchkey > midVal.shortcut){
1002 first = mid + 1; // Search in top half
1004 else if (searchkey < midVal.shortcut){
1005 last = mid - 1; // Search in bottom half
1008 //found correct shortcut value, now we must check for platform match
1009 if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
1011 } else { //We may have several equal values for different platforms, so we must search in both directions
1014 for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
1015 QKeyBinding current = QKeySequencePrivate::keyBindings[i];
1016 if (current.shortcut != searchkey)
1018 else if (current.platform & platform && current.standardKey == matchKey)
1023 for ( int i = mid - 1 ; i >= 0 ; --i) {
1024 QKeyBinding current = QKeySequencePrivate::keyBindings[i];
1025 if (current.shortcut != searchkey)
1027 else if (current.platform & platform && current.standardKey == matchKey)
1030 return false; //we could not find it among the matching keySequences
1034 return false; //we could not find matching keySequences at all
1036 #endif // QT_NO_SHORTCUT
1040 \fn bool QKeyEvent::isAutoRepeat() const
1042 Returns true if this event comes from an auto-repeating key;
1043 returns false if it comes from an initial key press.
1045 Note that if the event is a multiple-key compressed event that is
1046 partly due to auto-repeat, this function could return either true
1047 or false indeterminately.
1051 \fn int QKeyEvent::count() const
1053 Returns the number of keys involved in this event. If text()
1054 is not empty, this is simply the length of the string.
1056 \sa Qt::WA_KeyCompression
1061 \brief The QFocusEvent class contains event parameters for widget focus
1067 Focus events are sent to widgets when the keyboard input focus
1068 changes. Focus events occur due to mouse actions, key presses
1069 (such as \uicontrol{Tab} or \uicontrol{Backtab}), the window system, popup
1070 menus, keyboard shortcuts, or other application-specific reasons.
1071 The reason for a particular focus event is returned by reason()
1072 in the appropriate event handler.
1074 The event handlers QWidget::focusInEvent(),
1075 QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
1076 QGraphicsItem::focusOutEvent() receive focus events.
1078 \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
1082 Constructs a focus event object.
1084 The \a type parameter must be either QEvent::FocusIn or
1085 QEvent::FocusOut. The \a reason describes the cause of the change
1088 QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
1089 : QEvent(type), m_reason(reason)
1095 QFocusEvent::~QFocusEvent()
1100 Returns the reason for this focus event.
1102 Qt::FocusReason QFocusEvent::reason() const
1108 \fn bool QFocusEvent::gotFocus() const
1110 Returns true if type() is QEvent::FocusIn; otherwise returns
1115 \fn bool QFocusEvent::lostFocus() const
1117 Returns true if type() is QEvent::FocusOut; otherwise returns
1124 \brief The QPaintEvent class contains event parameters for paint events.
1129 Paint events are sent to widgets that need to update themselves,
1130 for instance when part of a widget is exposed because a covering
1133 The event contains a region() that needs to be updated, and a
1134 rect() that is the bounding rectangle of that region. Both are
1135 provided because many widgets can't make much use of region(),
1136 and rect() can be much faster than region().boundingRect().
1138 \section1 Automatic Clipping
1140 Painting is clipped to region() during the processing of a paint
1141 event. This clipping is performed by Qt's paint system and is
1142 independent of any clipping that may be applied to a QPainter used to
1143 draw on the paint device.
1145 As a result, the value returned by QPainter::clipRegion() on
1146 a newly-constructed QPainter will not reflect the clip region that is
1147 used by the paint system.
1149 \sa QPainter, QWidget::update(), QWidget::repaint(),
1150 QWidget::paintEvent()
1154 Constructs a paint event object with the region that needs to
1155 be updated. The region is specified by \a paintRegion.
1157 QPaintEvent::QPaintEvent(const QRegion& paintRegion)
1158 : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
1162 Constructs a paint event object with the rectangle that needs
1163 to be updated. The region is specified by \a paintRect.
1165 QPaintEvent::QPaintEvent(const QRect &paintRect)
1166 : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
1173 QPaintEvent::~QPaintEvent()
1178 \fn const QRect &QPaintEvent::rect() const
1180 Returns the rectangle that needs to be updated.
1182 \sa region(), QPainter::setClipRect()
1186 \fn const QRegion &QPaintEvent::region() const
1188 Returns the region that needs to be updated.
1190 \sa rect(), QPainter::setClipRegion()
1196 \brief The QMoveEvent class contains event parameters for move events.
1201 Move events are sent to widgets that have been moved to a new
1202 position relative to their parent.
1204 The event handler QWidget::moveEvent() receives move events.
1206 \sa QWidget::move(), QWidget::setGeometry()
1210 Constructs a move event with the new and old widget positions,
1211 \a pos and \a oldPos respectively.
1213 QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
1214 : QEvent(Move), p(pos), oldp(oldPos)
1220 QMoveEvent::~QMoveEvent()
1225 \fn const QPoint &QMoveEvent::pos() const
1227 Returns the new position of the widget. This excludes the window
1228 frame for top level widgets.
1232 \fn const QPoint &QMoveEvent::oldPos() const
1234 Returns the old position of the widget.
1240 \brief The QExposeEvent class contains event parameters for expose events.
1245 Expose events are sent to windows when an area of the window is invalidated
1246 or window visibility in the windowing system changes.
1248 The event handler QWindow::exposeEvent() receives expose events.
1252 Constructs an expose event for the given \a exposeRegion.
1254 QExposeEvent::QExposeEvent(const QRegion &exposeRegion)
1263 QExposeEvent::~QExposeEvent()
1268 \fn const QRegion &QExposeEvent::region() const
1270 Returns the window area that has been exposed.
1275 \brief The QResizeEvent class contains event parameters for resize events.
1280 Resize events are sent to widgets that have been resized.
1282 The event handler QWidget::resizeEvent() receives resize events.
1284 \sa QWidget::resize(), QWidget::setGeometry()
1288 Constructs a resize event with the new and old widget sizes, \a
1289 size and \a oldSize respectively.
1291 QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
1292 : QEvent(Resize), s(size), olds(oldSize)
1298 QResizeEvent::~QResizeEvent()
1303 \fn const QSize &QResizeEvent::size() const
1305 Returns the new size of the widget. This is the same as
1310 \fn const QSize &QResizeEvent::oldSize() const
1312 Returns the old size of the widget.
1318 \brief The QCloseEvent class contains parameters that describe a close event.
1323 Close events are sent to widgets that the user wants to close,
1324 usually by choosing "Close" from the window menu, or by clicking
1325 the \uicontrol{X} title bar button. They are also sent when you call
1326 QWidget::close() to close a widget programmatically.
1328 Close events contain a flag that indicates whether the receiver
1329 wants the widget to be closed or not. When a widget accepts the
1330 close event, it is hidden (and destroyed if it was created with
1331 the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
1332 event nothing happens. (Under X11 it is possible that the window
1333 manager will forcibly close the window; but at the time of writing
1334 we are not aware of any window manager that does this.)
1336 The event handler QWidget::closeEvent() receives close events. The
1337 default implementation of this event handler accepts the close
1338 event. If you do not want your widget to be hidden, or want some
1339 special handing, you should reimplement the event handler and
1342 The \l{mainwindows/application#close event handler}{closeEvent() in the
1343 Application example} shows a close event handler that
1344 asks whether to save a document before closing.
1346 If you want the widget to be deleted when it is closed, create it
1347 with the Qt::WA_DeleteOnClose flag. This is very useful for
1348 independent top-level windows in a multi-window application.
1350 \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
1351 signal when they are deleted.
1353 If the last top-level window is closed, the
1354 QApplication::lastWindowClosed() signal is emitted.
1356 The isAccepted() function returns true if the event's receiver has
1357 agreed to close the widget; call accept() to agree to close the
1358 widget and call ignore() if the receiver of this event does not
1359 want the widget to be closed.
1361 \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
1362 QCoreApplication::exec(), QCoreApplication::quit(),
1363 QApplication::lastWindowClosed()
1367 Constructs a close event object.
1371 QCloseEvent::QCloseEvent()
1377 QCloseEvent::~QCloseEvent()
1382 \class QIconDragEvent
1383 \brief The QIconDragEvent class indicates that a main icon drag has begun.
1388 Icon drag events are sent to widgets when the main icon of a window
1389 has been dragged away. On Mac OS X, this happens when the proxy
1390 icon of a window is dragged off the title bar.
1392 It is normal to begin using drag and drop in response to this
1395 \sa {Drag and Drop}, QMimeData, QDrag
1399 Constructs an icon drag event object with the accept flag set to
1404 QIconDragEvent::QIconDragEvent()
1409 QIconDragEvent::~QIconDragEvent()
1414 \class QContextMenuEvent
1415 \brief The QContextMenuEvent class contains parameters that describe a context menu event.
1420 Context menu events are sent to widgets when a user performs
1421 an action associated with opening a context menu.
1422 The actions required to open context menus vary between platforms;
1423 for example, on Windows, pressing the menu button or clicking the
1424 right mouse button will cause this event to be sent.
1426 When this event occurs it is customary to show a QMenu with a
1427 context menu, if this is relevant to the context.
1429 Context menu events contain a special accept flag that indicates
1430 whether the receiver accepted the event. If the event handler does
1431 not accept the event then, if possible, whatever triggered the event will be
1432 handled as a regular input event.
1435 #ifndef QT_NO_CONTEXTMENU
1437 Constructs a context menu event object with the accept parameter
1440 The \a reason parameter must be QContextMenuEvent::Mouse or
1441 QContextMenuEvent::Keyboard.
1443 The \a pos parameter specifies the mouse position relative to the
1444 receiving widget. \a globalPos is the mouse position in absolute
1447 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
1448 : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
1452 Constructs a context menu event object with the accept parameter
1455 The \a reason parameter must be QContextMenuEvent::Mouse or
1456 QContextMenuEvent::Keyboard.
1458 The \a pos parameter specifies the mouse position relative to the
1459 receiving widget. \a globalPos is the mouse position in absolute
1460 coordinates. The \a modifiers holds the keyboard modifiers.
1462 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
1463 Qt::KeyboardModifiers modifiers)
1464 : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
1469 QContextMenuEvent::~QContextMenuEvent()
1473 Constructs a context menu event object with the accept parameter
1476 The \a reason parameter must be QContextMenuEvent::Mouse or
1477 QContextMenuEvent::Keyboard.
1479 The \a pos parameter specifies the mouse position relative to the
1482 The globalPos() is initialized to QCursor::pos(), which may not be
1483 appropriate. Use the other constructor to specify the global
1484 position explicitly.
1486 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
1487 : QInputEvent(ContextMenu), p(pos), reas(reason)
1489 gp = QCursor::pos();
1493 \fn const QPoint &QContextMenuEvent::pos() const
1495 Returns the position of the mouse pointer relative to the widget
1496 that received the event.
1498 \sa x(), y(), globalPos()
1502 \fn int QContextMenuEvent::x() const
1504 Returns the x position of the mouse pointer, relative to the
1505 widget that received the event.
1511 \fn int QContextMenuEvent::y() const
1513 Returns the y position of the mouse pointer, relative to the
1514 widget that received the event.
1520 \fn const QPoint &QContextMenuEvent::globalPos() const
1522 Returns the global position of the mouse pointer at the time of
1529 \fn int QContextMenuEvent::globalX() const
1531 Returns the global x position of the mouse pointer at the time of
1534 \sa globalY(), globalPos()
1538 \fn int QContextMenuEvent::globalY() const
1540 Returns the global y position of the mouse pointer at the time of
1543 \sa globalX(), globalPos()
1545 #endif // QT_NO_CONTEXTMENU
1548 \enum QContextMenuEvent::Reason
1550 This enum describes the reason why the event was sent.
1552 \value Mouse The mouse caused the event to be sent. Normally this
1553 means the right mouse button was clicked, but this is platform
1556 \value Keyboard The keyboard caused this event to be sent. On
1557 Windows, this means the menu button was pressed.
1559 \value Other The event was sent by some other means (i.e. not by
1560 the mouse or keyboard).
1565 \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
1567 Returns the reason for this context event.
1572 \class QInputMethodEvent
1573 \brief The QInputMethodEvent class provides parameters for input method events.
1578 Input method events are sent to widgets when an input method is
1579 used to enter text into a widget. Input methods are widely used
1580 to enter text for languages with non-Latin alphabets.
1582 Note that when creating custom text editing widgets, the
1583 Qt::WA_InputMethodEnabled window attribute must be set explicitly
1584 (using the QWidget::setAttribute() function) in order to receive
1585 input method events.
1587 The events are of interest to authors of keyboard entry widgets
1588 who want to be able to correctly handle languages with complex
1589 character input. Text input in such languages is usually a three
1593 \li \b{Starting to Compose}
1595 When the user presses the first key on a keyboard, an input
1596 context is created. This input context will contain a string
1597 of the typed characters.
1601 With every new key pressed, the input method will try to create a
1602 matching string for the text typed so far called preedit
1603 string. While the input context is active, the user can only move
1604 the cursor inside the string belonging to this input context.
1608 At some point, the user will activate a user interface component
1609 (perhaps using a particular key) where they can choose from a
1610 number of strings matching the text they have typed so far. The
1611 user can either confirm their choice cancel the input; in either
1612 case the input context will be closed.
1615 QInputMethodEvent models these three stages, and transfers the
1616 information needed to correctly render the intermediate result. A
1617 QInputMethodEvent has two main parameters: preeditString() and
1618 commitString(). The preeditString() parameter gives the currently
1619 active preedit string. The commitString() parameter gives a text
1620 that should get added to (or replace parts of) the text of the
1621 editor widget. It usually is a result of the input operations and
1622 has to be inserted to the widgets text directly before the preedit
1625 If the commitString() should replace parts of the of the text in
1626 the editor, replacementLength() will contain the number of
1627 characters to be replaced. replacementStart() contains the position
1628 at which characters are to be replaced relative from the start of
1631 A number of attributes control the visual appearance of the
1632 preedit string (the visual appearance of text outside the preedit
1633 string is controlled by the widget only). The AttributeType enum
1634 describes the different attributes that can be set.
1636 A class implementing QWidget::inputMethodEvent() or
1637 QGraphicsItem::inputMethodEvent() should at least understand and
1638 honor the \l TextFormat and \l Cursor attributes.
1640 Since input methods need to be able to query certain properties
1641 from the widget or graphics item, subclasses must also implement
1642 QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
1645 When receiving an input method event, the text widget has to performs the
1649 \li If the widget has selected text, the selected text should get
1652 \li Remove the text starting at replacementStart() with length
1653 replacementLength() and replace it by the commitString(). If
1654 replacementLength() is 0, replacementStart() gives the insertion
1655 position for the commitString().
1657 When doing replacement the area of the preedit
1658 string is ignored, thus a replacement starting at -1 with a length
1659 of 2 will remove the last character before the preedit string and
1660 the first character afterwards, and insert the commit string
1661 directly before the preedit string.
1663 If the widget implements undo/redo, this operation gets added to
1666 \li If there is no current preedit string, insert the
1667 preeditString() at the current cursor position; otherwise replace
1668 the previous preeditString with the one received from this event.
1670 If the widget implements undo/redo, the preeditString() should not
1671 influence the undo/redo stack in any way.
1673 The widget should examine the list of attributes to apply to the
1674 preedit string. It has to understand at least the TextFormat and
1675 Cursor attributes and render them as specified.
1682 \enum QInputMethodEvent::AttributeType
1685 A QTextCharFormat for the part of the preedit string specified by
1686 start and length. value contains a QVariant of type QTextFormat
1687 specifying rendering of this part of the preedit string. There
1688 should be at most one format for every part of the preedit
1689 string. If several are specified for any character in the string the
1690 behaviour is undefined. A conforming implementation has to at least
1691 honor the backgroundColor, textColor and fontUnderline properties
1694 \value Cursor If set, a cursor should be shown inside the preedit
1695 string at position start. The length variable determines whether
1696 the cursor is visible or not. If the length is 0 the cursor is
1697 invisible. If value is a QVariant of type QColor this color will
1698 be used for rendering the cursor, otherwise the color of the
1699 surrounding text will be used. There should be at most one Cursor
1700 attribute per event. If several are specified the behaviour is
1704 The variant contains a QLocale object specifying the language of a
1705 certain part of the preedit string. There should be at most one
1706 language set for every part of the preedit string. If several are
1707 specified for any character in the string the behavior is undefined.
1710 The ruby text for a part of the preedit string. There should be at
1711 most one ruby text set for every part of the preedit string. If
1712 several are specified for any character in the string the behaviour
1716 If set, the edit cursor should be moved to the specified position
1717 in the editor text contents. In contrast with \c Cursor, this
1718 attribute does not work on the preedit text, but on the surrounding
1719 text. The cursor will be moved after the commit string has been
1720 committed, and the preedit string will be located at the new edit
1722 The start position specifies the new position and the length
1723 variable can be used to set a selection starting from that point.
1724 The value is unused.
1730 \class QInputMethodEvent::Attribute
1731 \brief The QInputMethodEvent::Attribute class stores an input method attribute.
1735 \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
1737 Constructs an input method attribute. \a type specifies the type
1738 of attribute, \a start and \a length the position of the
1739 attribute, and \a value the value of the attribute.
1743 Constructs an event of type QEvent::InputMethod. The
1744 attributes(), preeditString(), commitString(), replacementStart(),
1745 and replacementLength() are initialized to default values.
1747 \sa setCommitString()
1749 QInputMethodEvent::QInputMethodEvent()
1750 : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
1755 Construcs an event of type QEvent::InputMethod. The
1756 preedit text is set to \a preeditText, the attributes to
1759 The commitString(), replacementStart(), and replacementLength()
1760 values can be set using setCommitString().
1762 \sa preeditString(), attributes()
1764 QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
1765 : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
1766 replace_from(0), replace_length(0)
1771 Constructs a copy of \a other.
1773 QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
1774 : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
1775 commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
1780 Sets the commit string to \a commitString.
1782 The commit string is the text that should get added to (or
1783 replace parts of) the text of the editor widget. It usually is a
1784 result of the input operations and has to be inserted to the
1785 widgets text directly before the preedit string.
1787 If the commit string should replace parts of the of the text in
1788 the editor, \a replaceLength specifies the number of
1789 characters to be replaced. \a replaceFrom specifies the position
1790 at which characters are to be replaced relative from the start of
1793 \sa commitString(), replacementStart(), replacementLength()
1795 void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
1797 commit = commitString;
1798 replace_from = replaceFrom;
1799 replace_length = replaceLength;
1803 \fn const QList<Attribute> &QInputMethodEvent::attributes() const
1805 Returns the list of attributes passed to the QInputMethodEvent
1806 constructor. The attributes control the visual appearance of the
1807 preedit string (the visual appearance of text outside the preedit
1808 string is controlled by the widget only).
1810 \sa preeditString(), Attribute
1814 \fn const QString &QInputMethodEvent::preeditString() const
1816 Returns the preedit text, i.e. the text before the user started
1819 \sa commitString(), attributes()
1823 \fn const QString &QInputMethodEvent::commitString() const
1825 Returns the text that should get added to (or replace parts of)
1826 the text of the editor widget. It usually is a result of the
1827 input operations and has to be inserted to the widgets text
1828 directly before the preedit string.
1830 \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
1834 \fn int QInputMethodEvent::replacementStart() const
1836 Returns the position at which characters are to be replaced relative
1837 from the start of the preedit string.
1839 \sa replacementLength(), setCommitString()
1843 \fn int QInputMethodEvent::replacementLength() const
1845 Returns the number of characters to be replaced in the preedit
1848 \sa replacementStart(), setCommitString()
1852 \class QInputMethodQueryEvent
1856 \brief The QInputMethodQueryEvent class provides an event sent by the input context to input objects.
1859 input method to query a set of properties of the object to be
1860 able to support complex input method operations as support for
1861 surrounding text and reconversions.
1863 queries() specifies which properties are queried.
1865 The object should call setValue() on the event to fill in the requested
1866 data before calling accept().
1870 \fn Qt::InputMethodQueries QInputMethodQueryEvent::queries() const
1872 Returns the properties queried by the event.
1876 Constructs a query event for properties given by \a queries.
1878 QInputMethodQueryEvent::QInputMethodQueryEvent(Qt::InputMethodQueries queries)
1879 : QEvent(InputMethodQuery),
1887 QInputMethodQueryEvent::~QInputMethodQueryEvent()
1892 Sets property \a query to \a value.
1894 void QInputMethodQueryEvent::setValue(Qt::InputMethodQuery query, const QVariant &value)
1896 for (int i = 0; i < m_values.size(); ++i) {
1897 if (m_values.at(i).query == query) {
1898 m_values[i].value = value;
1902 QueryPair pair = { query, value };
1903 m_values.append(pair);
1907 Returns value of the property \a query.
1909 QVariant QInputMethodQueryEvent::value(Qt::InputMethodQuery query) const
1911 for (int i = 0; i < m_values.size(); ++i)
1912 if (m_values.at(i).query == query)
1913 return m_values.at(i).value;
1917 #ifndef QT_NO_TABLETEVENT
1921 \brief The QTabletEvent class contains parameters that describe a Tablet event.
1926 Tablet Events are generated from a Wacom tablet. Most of the time you will
1927 want to deal with events from the tablet as if they were events from a
1928 mouse; for example, you would retrieve the cursor position with x(), y(),
1929 pos(), globalX(), globalY(), and globalPos(). In some situations you may
1930 wish to retrieve the extra information provided by the tablet device
1931 driver; for example, you might want to do subpixeling with higher
1932 resolution coordinates or you may want to adjust color brightness based on
1933 pressure. QTabletEvent allows you to read the pressure(), the xTilt(), and
1934 yTilt(), as well as the type of device being used with device() (see
1935 \l{TabletDevice}). It can also give you the minimum and maximum values for
1936 each device's pressure and high resolution coordinates.
1938 A tablet event contains a special accept flag that indicates whether the
1939 receiver wants the event. You should call QTabletEvent::accept() if you
1940 handle the tablet event; otherwise it will be sent to the parent widget.
1941 The exception are TabletEnterProximity and TabletLeaveProximity events,
1942 these are only sent to QApplication and don't check whether or not they are
1945 The QWidget::setEnabled() function can be used to enable or
1946 disable mouse and keyboard events for a widget.
1948 The event handler QWidget::tabletEvent() receives all three types of
1949 tablet events. Qt will first send a tabletEvent then, if it is not
1950 accepted, it will send a mouse event. This allows applications that
1951 don't utilize tablets to use a tablet like a mouse, while also
1952 enabling those who want to use both tablets and mouses differently.
1954 \section1 Notes for X11 Users
1956 Qt uses the following hard-coded names to identify tablet
1957 devices from the xorg.conf file on X11 (apart from IRIX):
1958 'stylus', 'pen', and 'eraser'. If the devices have other names,
1959 they will not be picked up Qt.
1963 \enum QTabletEvent::TabletDevice
1965 This enum defines what type of device is generating the event.
1967 \value NoDevice No device, or an unknown device.
1968 \value Puck A Puck (a device that is similar to a flat mouse with
1969 a transparent circle with cross-hairs).
1970 \value Stylus A Stylus.
1971 \value Airbrush An airbrush
1972 \value FourDMouse A 4D Mouse.
1973 \value RotationStylus A special stylus that also knows about rotation
1974 (a 6D stylus). \since 4.1
1975 \omitvalue XFreeEraser
1979 \enum QTabletEvent::PointerType
1981 This enum defines what type of point is generating the event.
1983 \value UnknownPointer An unknown device.
1984 \value Pen Tip end of a stylus-like device (the narrow end of the pen).
1985 \value Cursor Any puck-like device.
1986 \value Eraser Eraser end of a stylus-like device (the broad end of the pen).
1992 Construct a tablet event of the given \a type.
1994 The \a pos parameter indicates where the event occurred in the
1995 widget; \a globalPos is the corresponding position in absolute
1998 \a pressure contains the pressure exerted on the \a device.
2000 \a pointerType describes the type of pen that is being used.
2002 \a xTilt and \a yTilt contain the device's degree of tilt from the
2003 x and y axes respectively.
2005 \a keyState specifies which keyboard modifiers are pressed (e.g.,
2008 The \a uniqueID parameter contains the unique ID for the current device.
2010 The \a z parameter contains the coordinate of the device on the tablet, this
2011 is usually given by a wheel on 4D mouse. If the device does not support a
2012 Z-axis, pass zero here.
2014 The \a tangentialPressure parameter contins the tangential pressure of an air
2015 brush. If the device does not support tangential pressure, pass 0 here.
2017 \a rotation contains the device's rotation in degrees. 4D mice support
2018 rotation. If the device does not support rotation, pass 0 here.
2020 \sa pos(), globalPos(), device(), pressure(), xTilt(), yTilt(), uniqueId(), rotation(),
2021 tangentialPressure(), z()
2024 QTabletEvent::QTabletEvent(Type type, const QPointF &pos, const QPointF &globalPos,
2025 int device, int pointerType,
2026 qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
2027 qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
2028 : QInputEvent(type, keyState),
2032 mPointerType(pointerType),
2037 mTangential(tangentialPressure),
2047 QTabletEvent::~QTabletEvent()
2052 \fn TabletDevices QTabletEvent::device() const
2054 Returns the type of device that generated the event.
2060 \fn PointerType QTabletEvent::pointerType() const
2062 Returns the type of point that generated the event.
2066 \fn qreal QTabletEvent::tangentialPressure() const
2068 Returns the tangential pressure for the device. This is typically given by a finger
2069 wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a
2070 neutral position. Current airbrushes can only move in the positive
2071 direction from the neutrual position. If the device does not support
2072 tangential pressure, this value is always 0.0.
2078 \fn qreal QTabletEvent::rotation() const
2080 Returns the rotation of the current device in degress. This is usually
2081 given by a 4D Mouse. If the device doesn't support rotation this value is
2087 \fn qreal QTabletEvent::pressure() const
2089 Returns the pressure for the device. 0.0 indicates that the stylus is not
2090 on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
2092 \sa tangentialPressure()
2096 \fn int QTabletEvent::xTilt() const
2098 Returns the angle between the device (a pen, for example) and the
2099 perpendicular in the direction of the x axis.
2100 Positive values are towards the tablet's physical right. The angle
2101 is in the range -60 to +60 degrees.
2103 \image qtabletevent-tilt.png
2109 \fn int QTabletEvent::yTilt() const
2111 Returns the angle between the device (a pen, for example) and the
2112 perpendicular in the direction of the y axis.
2113 Positive values are towards the bottom of the tablet. The angle is
2114 within the range -60 to +60 degrees.
2120 \fn QPoint QTabletEvent::pos() const
2122 Returns the position of the device, relative to the widget that
2125 If you move widgets around in response to mouse events, use
2126 globalPos() instead of this function.
2128 \sa x(), y(), globalPos()
2132 \fn int QTabletEvent::x() const
2134 Returns the x position of the device, relative to the widget that
2141 \fn int QTabletEvent::y() const
2143 Returns the y position of the device, relative to the widget that
2150 \fn int QTabletEvent::z() const
2152 Returns the z position of the device. Typically this is represented by a
2153 wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
2154 always zero. This is \b not the same as pressure.
2160 \fn QPoint QTabletEvent::globalPos() const
2162 Returns the global position of the device \e{at the time of the
2163 event}. This is important on asynchronous windows systems like X11;
2164 whenever you move your widgets around in response to mouse events,
2165 globalPos() can differ significantly from the current position
2168 \sa globalX(), globalY(), hiResGlobalPos()
2172 \fn int QTabletEvent::globalX() const
2174 Returns the global x position of the mouse pointer at the time of
2177 \sa globalY(), globalPos(), hiResGlobalX()
2181 \fn int QTabletEvent::globalY() const
2183 Returns the global y position of the tablet device at the time of
2186 \sa globalX(), globalPos(), hiResGlobalY()
2190 \fn qint64 QTabletEvent::uniqueId() const
2192 Returns a unique ID for the current device, making it possible
2193 to differentiate between multiple devices being used at the same
2196 Support of this feature is dependent on the tablet.
2198 Values for the same device may vary from OS to OS.
2200 Later versions of the Wacom driver for Linux will now report
2201 the ID information. If you have a tablet that supports unique ID
2202 and are not getting the information on Linux, consider upgrading
2205 As of Qt 4.2, the unique ID is the same regardless of the orientation
2206 of the pen. Earlier versions would report a different value when using
2207 the eraser-end versus the pen-end of the stylus on some OS's.
2213 \fn const QPointF &QTabletEvent::hiResGlobalPos() const
2215 The high precision coordinates delivered from the tablet expressed.
2216 Sub pixeling information is in the fractional part of the QPointF.
2218 \sa globalPos(), hiResGlobalX(), hiResGlobalY()
2222 \fn qreal &QTabletEvent::hiResGlobalX() const
2224 The high precision x position of the tablet device.
2228 \fn qreal &QTabletEvent::hiResGlobalY() const
2230 The high precision y position of the tablet device.
2234 \fn const QPointF &QTabletEvent::posF() const
2236 Returns the position of the device, relative to the widget that
2239 If you move widgets around in response to mouse events, use
2240 globalPosF() instead of this function.
2246 \fn const QPointF &QTabletEvent::globalPosF() const
2248 Returns the global position of the device \e{at the time of the
2249 event}. This is important on asynchronous windows systems like X11;
2250 whenever you move your widgets around in response to mouse events,
2251 globalPosF() can differ significantly from the current position
2257 #endif // QT_NO_TABLETEVENT
2259 #ifndef QT_NO_DRAGANDDROP
2261 Creates a QDragMoveEvent of the required \a type indicating
2262 that the mouse is at position \a pos given within a widget.
2264 The mouse and keyboard states are specified by \a buttons and
2265 \a modifiers, and the \a actions describe the types of drag
2266 and drop operation that are possible.
2267 The drag data is passed as MIME-encoded information in \a data.
2269 \warning Do not attempt to create a QDragMoveEvent yourself.
2270 These objects rely on Qt's internal state.
2272 QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2273 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2274 : QDropEvent(pos, actions, data, buttons, modifiers, type)
2275 , rect(pos, QSize(1, 1))
2281 QDragMoveEvent::~QDragMoveEvent()
2286 \fn void QDragMoveEvent::accept(const QRect &rectangle)
2288 The same as accept(), but also notifies that future moves will
2289 also be acceptable if they remain within the \a rectangle
2290 given on the widget. This can improve performance, but may
2291 also be ignored by the underlying system.
2293 If the rectangle is empty, drag move events will be sent
2294 continuously. This is useful if the source is scrolling in a
2299 \fn void QDragMoveEvent::accept()
2303 Calls QDropEvent::accept().
2307 \fn void QDragMoveEvent::ignore()
2311 Calls QDropEvent::ignore().
2315 \fn void QDragMoveEvent::ignore(const QRect &rectangle)
2317 The opposite of the accept(const QRect&) function.
2318 Moves within the \a rectangle are not acceptable, and will be
2323 \fn QRect QDragMoveEvent::answerRect() const
2325 Returns the rectangle in the widget where the drop will occur if accepted.
2326 You can use this information to restrict drops to certain places on the
2334 \ingroup draganddrop
2337 \brief The QDropEvent class provides an event which is sent when a
2338 drag and drop action is completed.
2340 When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
2341 receive this event if it has accepted the most recent QDragEnterEvent or
2342 QDragMoveEvent sent to it.
2344 The drop event contains a proposed action, available from proposedAction(), for
2345 the widget to either accept or ignore. If the action can be handled by the
2346 widget, you should call the acceptProposedAction() function. Since the
2347 proposed action can be a combination of \l Qt::DropAction values, it may be
2348 useful to either select one of these values as a default action or ask
2349 the user to select their preferred action.
2351 If the proposed drop action is not suitable, perhaps because your custom
2352 widget does not support that action, you can replace it with any of the
2353 \l{possibleActions()}{possible drop actions} by calling setDropAction()
2354 with your preferred action. If you set a value that is not present in the
2355 bitwise OR combination of values returned by possibleActions(), the default
2356 copy action will be used. Once a replacement drop action has been set, call
2357 accept() instead of acceptProposedAction() to complete the drop operation.
2359 The mimeData() function provides the data dropped on the widget in a QMimeData
2360 object. This contains information about the MIME type of the data in addition to
2363 \sa QMimeData, QDrag, {Drag and Drop}
2367 \fn const QMimeData *QDropEvent::mimeData() const
2369 Returns the data that was dropped on the widget and its associated MIME
2374 Constructs a drop event of a certain \a type corresponding to a
2375 drop at the point specified by \a pos in the destination widget's
2378 The \a actions indicate which types of drag and drop operation can
2379 be performed, and the drag data is stored as MIME-encoded data in \a data.
2381 The states of the mouse buttons and keyboard modifiers at the time of
2382 the drop are specified by \a buttons and \a modifiers.
2383 */ // ### pos is in which coordinate system?
2384 QDropEvent::QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data,
2385 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2386 : QEvent(type), p(pos), mouseState(buttons),
2387 modState(modifiers), act(actions),
2390 default_action = QGuiApplicationPrivate::platformIntegration()->drag()->defaultAction(act, modifiers);
2391 drop_action = default_action;
2396 QDropEvent::~QDropEvent()
2402 If the source of the drag operation is a widget in this
2403 application, this function returns that source; otherwise it
2404 returns 0. The source of the operation is the first parameter to
2405 the QDrag object used instantiate the drag.
2407 This is useful if your widget needs special behavior when dragging
2412 QObject* QDropEvent::source() const
2414 if (const QDragManager *manager = QDragManager::self())
2415 return manager->source();
2420 void QDropEvent::setDropAction(Qt::DropAction action)
2422 if (!(action & act) && action != Qt::IgnoreAction)
2423 action = default_action;
2424 drop_action = action;
2428 \fn QPoint QDropEvent::pos() const
2430 Returns the position where the drop was made.
2434 \fn const QPointF& QDropEvent::posF() const
2436 Returns the position where the drop was made.
2440 \fn Qt::MouseButtons QDropEvent::mouseButtons() const
2442 Returns the mouse buttons that are pressed..
2446 \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
2448 Returns the modifier keys that are pressed.
2452 \fn void QDropEvent::setDropAction(Qt::DropAction action)
2454 Sets the \a action to be performed on the data by the target.
2455 Use this to override the \l{proposedAction()}{proposed action}
2456 with one of the \l{possibleActions()}{possible actions}.
2458 If you set a drop action that is not one of the possible actions, the
2459 drag and drop operation will default to a copy operation.
2461 Once you have supplied a replacement drop action, call accept()
2462 instead of acceptProposedAction().
2468 \fn Qt::DropAction QDropEvent::dropAction() const
2470 Returns the action to be performed on the data by the target. This may be
2471 different from the action supplied in proposedAction() if you have called
2472 setDropAction() to explicitly choose a drop action.
2478 \fn Qt::DropActions QDropEvent::possibleActions() const
2480 Returns an OR-combination of possible drop actions.
2486 \fn Qt::DropAction QDropEvent::proposedAction() const
2488 Returns the proposed drop action.
2494 \fn void QDropEvent::acceptProposedAction()
2496 Sets the drop action to be the proposed action.
2498 \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
2502 \class QDragEnterEvent
2503 \brief The QDragEnterEvent class provides an event which is sent
2504 to a widget when a drag and drop action enters it.
2507 \ingroup draganddrop
2510 A widget must accept this event in order to receive the \l
2511 {QDragMoveEvent}{drag move events} that are sent while the drag
2512 and drop action is in progress. The drag enter event is always
2513 immediately followed by a drag move event.
2515 QDragEnterEvent inherits most of its functionality from
2516 QDragMoveEvent, which in turn inherits most of its functionality
2519 \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
2523 Constructs a QDragEnterEvent that represents a drag entering a
2524 widget at the given \a point with mouse and keyboard states specified by
2525 \a buttons and \a modifiers.
2527 The drag data is passed as MIME-encoded information in \a data, and the
2528 specified \a actions describe the possible types of drag and drop
2529 operation that can be performed.
2531 \warning Do not create a QDragEnterEvent yourself since these
2532 objects rely on Qt's internal state.
2534 QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
2535 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
2536 : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
2541 QDragEnterEvent::~QDragEnterEvent()
2546 \class QDragMoveEvent
2547 \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
2550 \ingroup draganddrop
2553 A widget will receive drag move events repeatedly while the drag
2554 is within its boundaries, if it accepts
2555 \l{QWidget::setAcceptDrops()}{drop events} and \l
2556 {QWidget::dragEnterEvent()}{enter events}. The widget should
2557 examine the event to see what kind of data it
2558 \l{QDragMoveEvent::provides()}{provides}, and call the accept()
2559 function to accept the drop if appropriate.
2561 The rectangle supplied by the answerRect() function can be used to restrict
2562 drops to certain parts of the widget. For example, we can check whether the
2563 rectangle intersects with the geometry of a certain child widget and only
2564 call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
2567 Note that this class inherits most of its functionality from
2570 \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
2574 \class QDragLeaveEvent
2575 \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
2578 \ingroup draganddrop
2581 This event is always preceded by a QDragEnterEvent and a series
2582 of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
2585 \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
2589 Constructs a QDragLeaveEvent.
2591 \warning Do not create a QDragLeaveEvent yourself since these
2592 objects rely on Qt's internal state.
2594 QDragLeaveEvent::QDragLeaveEvent()
2600 QDragLeaveEvent::~QDragLeaveEvent()
2603 #endif // QT_NO_DRAGANDDROP
2607 \brief The QHelpEvent class provides an event that is used to request helpful information
2608 about a particular point in a widget.
2614 This event can be intercepted in applications to provide tooltips
2615 or "What's This?" help for custom widgets. The type() can be
2616 either QEvent::ToolTip or QEvent::WhatsThis.
2618 \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
2622 Constructs a help event with the given \a type corresponding to the
2623 widget-relative position specified by \a pos and the global position
2624 specified by \a globalPos.
2626 \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
2628 \sa pos(), globalPos()
2630 QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
2631 : QEvent(type), p(pos), gp(globalPos)
2635 \fn int QHelpEvent::x() const
2639 \sa y(), pos(), globalPos()
2643 \fn int QHelpEvent::y() const
2647 \sa x(), pos(), globalPos()
2651 \fn int QHelpEvent::globalX() const
2653 Same as globalPos().x().
2655 \sa x(), globalY(), globalPos()
2659 \fn int QHelpEvent::globalY() const
2661 Same as globalPos().y().
2663 \sa y(), globalX(), globalPos()
2667 \fn const QPoint &QHelpEvent::pos() const
2669 Returns the mouse cursor position when the event was generated,
2670 relative to the widget to which the event is dispatched.
2672 \sa globalPos(), x(), y()
2676 \fn const QPoint &QHelpEvent::globalPos() const
2678 Returns the mouse cursor position when the event was generated
2679 in global coordinates.
2681 \sa pos(), globalX(), globalY()
2686 QHelpEvent::~QHelpEvent()
2690 #ifndef QT_NO_STATUSTIP
2693 \class QStatusTipEvent
2694 \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
2700 Status tips can be set on a widget using the
2701 QWidget::setStatusTip() function. They are shown in the status
2702 bar when the mouse cursor enters the widget. For example:
2707 \snippet qstatustipevent/main.cpp 1
2709 \snippet qstatustipevent/main.cpp 3
2711 \image qstatustipevent-widget.png Widget with status tip.
2714 Status tips can also be set on actions using the
2715 QAction::setStatusTip() function:
2720 \snippet qstatustipevent/main.cpp 0
2721 \snippet qstatustipevent/main.cpp 2
2723 \snippet qstatustipevent/main.cpp 3
2725 \image qstatustipevent-action.png Action with status tip.
2728 Finally, status tips are supported for the item view classes
2729 through the Qt::StatusTipRole enum value.
2731 \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
2735 Constructs a status tip event with the text specified by \a tip.
2739 QStatusTipEvent::QStatusTipEvent(const QString &tip)
2740 : QEvent(StatusTip), s(tip)
2745 QStatusTipEvent::~QStatusTipEvent()
2750 \fn QString QStatusTipEvent::tip() const
2752 Returns the message to show in the status bar.
2754 \sa QStatusBar::showMessage()
2757 #endif // QT_NO_STATUSTIP
2759 #ifndef QT_NO_WHATSTHIS
2762 \class QWhatsThisClickedEvent
2763 \brief The QWhatsThisClickedEvent class provides an event that
2764 can be used to handle hyperlinks in a "What's This?" text.
2770 \sa QWhatsThis, QHelpEvent, QStatusTipEvent
2774 Constructs an event containing a URL specified by \a href when a link
2775 is clicked in a "What's This?" message.
2779 QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
2780 : QEvent(WhatsThisClicked), s(href)
2785 QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
2790 \fn QString QWhatsThisClickedEvent::href() const
2792 Returns the URL that was clicked by the user in the "What's
2796 #endif // QT_NO_WHATSTHIS
2798 #ifndef QT_NO_ACTION
2802 \brief The QActionEvent class provides an event that is generated
2803 when a QAction is added, removed, or changed.
2808 Actions can be added to widgets using QWidget::addAction(). This
2809 generates an \l ActionAdded event, which you can handle to provide
2810 custom behavior. For example, QToolBar reimplements
2811 QWidget::actionEvent() to create \l{QToolButton}s for the
2814 \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
2818 Constructs an action event. The \a type can be \l ActionChanged,
2819 \l ActionAdded, or \l ActionRemoved.
2821 \a action is the action that is changed, added, or removed. If \a
2822 type is ActionAdded, the action is to be inserted before the
2823 action \a before. If \a before is 0, the action is appended.
2825 QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
2826 : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
2831 QActionEvent::~QActionEvent()
2836 \fn QAction *QActionEvent::action() const
2838 Returns the action that is changed, added, or removed.
2844 \fn QAction *QActionEvent::before() const
2846 If type() is \l ActionAdded, returns the action that should
2847 appear before action(). If this function returns 0, the action
2848 should be appended to already existing actions on the same
2851 \sa action(), QWidget::actions()
2854 #endif // QT_NO_ACTION
2858 \brief The QHideEvent class provides an event which is sent after a widget is hidden.
2863 This event is sent just before QWidget::hide() returns, and also
2864 when a top-level window has been hidden (iconified) by the user.
2866 If spontaneous() is true, the event originated outside the
2867 application. In this case, the user hid the window using the
2868 window manager controls, either by iconifying the window or by
2869 switching to another virtual desktop where the window isn't
2870 visible. The window will become hidden but not withdrawn. If the
2871 window was iconified, QWidget::isMinimized() returns true.
2877 Constructs a QHideEvent.
2879 QHideEvent::QHideEvent()
2885 QHideEvent::~QHideEvent()
2891 \brief The QShowEvent class provides an event that is sent when a widget is shown.
2896 There are two kinds of show events: show events caused by the
2897 window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
2898 show events are sent just after the window system shows the
2899 window; they are also sent when a top-level window is redisplayed
2900 after being iconified. Internal show events are delivered just
2901 before the widget becomes visible.
2907 Constructs a QShowEvent.
2909 QShowEvent::QShowEvent()
2915 QShowEvent::~QShowEvent()
2920 \class QFileOpenEvent
2921 \brief The QFileOpenEvent class provides an event that will be
2922 sent when there is a request to open a file or a URL.
2927 File open events will be sent to the QApplication::instance()
2928 when the operating system requests that a file or URL should be opened.
2929 This is a high-level event that can be caused by different user actions
2930 depending on the user's desktop environment; for example, double
2931 clicking on an file icon in the Finder on Mac OS X.
2933 This event is only used to notify the application of a request.
2934 It may be safely ignored.
2936 \note This class is currently supported for Mac OS X only.
2942 Constructs a file open event for the given \a file.
2944 QFileOpenEvent::QFileOpenEvent(const QString &file)
2945 : QEvent(FileOpen), f(file), m_url(QUrl::fromLocalFile(file))
2952 Constructs a file open event for the given \a url.
2954 QFileOpenEvent::QFileOpenEvent(const QUrl &url)
2955 : QEvent(FileOpen), f(url.toLocalFile()), m_url(url)
2962 QFileOpenEvent::~QFileOpenEvent()
2967 \fn QString QFileOpenEvent::file() const
2969 Returns the file that is being opened.
2973 \fn QUrl QFileOpenEvent::url() const
2975 Returns the url that is being opened.
2981 \fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2983 Opens a QFile on the \a file referenced by this event in the mode specified
2984 by \a flags. Returns true if successful; otherwise returns false.
2986 This is necessary as some files cannot be opened by name, but require specific
2987 information stored in this event.
2991 bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
2993 file.setFileName(f);
2994 return file.open(flags);
2997 #ifndef QT_NO_TOOLBAR
3000 \class QToolBarChangeEvent
3001 \brief The QToolBarChangeEvent class provides an event that is
3002 sent whenever a the toolbar button is clicked on Mac OS X.
3007 The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
3008 OS X, this is the long oblong button on the right side of the window
3009 title bar. The default implementation is to toggle the appearance (hidden or
3010 shown) of the associated toolbars for the window.
3016 Construct a QToolBarChangeEvent given the current button state in \a state.
3018 QToolBarChangeEvent::QToolBarChangeEvent(bool t)
3019 : QEvent(ToolBarChange), tog(t)
3024 QToolBarChangeEvent::~QToolBarChangeEvent()
3029 \fn bool QToolBarChangeEvent::toggle() const
3034 \fn Qt::ButtonState QToolBarChangeEvent::state() const
3036 Returns the keyboard modifier flags at the time of the event.
3038 The returned value is a selection of the following values,
3039 combined using the OR operator:
3040 Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
3043 #endif // QT_NO_TOOLBAR
3045 #ifndef QT_NO_SHORTCUT
3048 Constructs a shortcut event for the given \a key press,
3049 associated with the QShortcut ID \a id.
3051 \a ambiguous specifies whether there is more than one QShortcut
3052 for the same key sequence.
3054 QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
3055 : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
3060 Destroys the event object.
3062 QShortcutEvent::~QShortcutEvent()
3066 #endif // QT_NO_SHORTCUT
3068 #ifndef QT_NO_DEBUG_STREAM
3069 QDebug operator<<(QDebug dbg, const QEvent *e) {
3070 // More useful event output could be added here
3072 return dbg << "QEvent(this = 0x0)";
3074 switch (e->type()) {
3078 case QEvent::MouseButtonPress:
3079 case QEvent::MouseMove:
3080 case QEvent::MouseButtonRelease:
3081 case QEvent::MouseButtonDblClick:
3083 const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
3084 switch(me->type()) {
3085 case QEvent::MouseButtonPress:
3086 n = "MouseButtonPress";
3088 case QEvent::MouseMove:
3091 case QEvent::MouseButtonRelease:
3092 n = "MouseButtonRelease";
3094 case QEvent::MouseButtonDblClick:
3096 n = "MouseButtonDblClick";
3099 dbg.nospace() << "QMouseEvent(" << n
3100 << ", " << me->button()
3101 << ", " << hex << (int)me->buttons()
3102 << ", " << hex << (int)me->modifiers()
3107 #ifndef QT_NO_TOOLTIP
3108 case QEvent::ToolTip:
3112 case QEvent::WindowActivate:
3113 n = "WindowActivate";
3115 case QEvent::WindowDeactivate:
3116 n = "WindowDeactivate";
3118 case QEvent::ActivationChange:
3119 n = "ActivationChange";
3121 #ifndef QT_NO_WHEELEVENT
3123 dbg.nospace() << "QWheelEvent("
3124 << static_cast<const QWheelEvent *>(e)->pixelDelta()
3125 << static_cast<const QWheelEvent *>(e)->angleDelta()
3129 case QEvent::KeyPress:
3130 case QEvent::KeyRelease:
3131 case QEvent::ShortcutOverride:
3133 const QKeyEvent *ke = static_cast<const QKeyEvent*>(e);
3134 switch(ke->type()) {
3135 case QEvent::ShortcutOverride:
3136 n = "ShortcutOverride";
3138 case QEvent::KeyRelease:
3141 case QEvent::KeyPress:
3146 dbg.nospace() << "QKeyEvent(" << n
3147 << ", " << hex << ke->key()
3148 << ", " << hex << (int)ke->modifiers()
3149 << ", \"" << ke->text()
3150 << "\", " << ke->isAutoRepeat()
3151 << ", " << ke->count()
3155 case QEvent::FocusIn:
3158 case QEvent::FocusOut:
3167 case QEvent::PaletteChange:
3168 n = "PaletteChange";
3170 case QEvent::PolishRequest:
3171 n = "PolishRequest";
3173 case QEvent::Polish:
3176 case QEvent::UpdateRequest:
3177 n = "UpdateRequest";
3185 case QEvent::Resize:
3188 case QEvent::Create:
3191 case QEvent::Destroy:
3200 case QEvent::FileOpen:
3206 case QEvent::ShowToParent:
3212 case QEvent::HideToParent:
3218 case QEvent::ParentChange:
3221 case QEvent::ParentAboutToChange:
3222 n = "ParentAboutToChange";
3224 case QEvent::HoverEnter:
3227 case QEvent::HoverMove:
3230 case QEvent::HoverLeave:
3233 case QEvent::ZOrderChange:
3236 case QEvent::StyleChange:
3239 case QEvent::DragEnter:
3242 case QEvent::DragMove:
3245 case QEvent::DragLeave:
3251 case QEvent::GraphicsSceneMouseMove:
3252 n = "GraphicsSceneMouseMove";
3254 case QEvent::GraphicsSceneMousePress:
3255 n = "GraphicsSceneMousePress";
3257 case QEvent::GraphicsSceneMouseRelease:
3258 n = "GraphicsSceneMouseRelease";
3260 case QEvent::GraphicsSceneMouseDoubleClick:
3261 n = "GraphicsSceneMouseDoubleClick";
3263 case QEvent::GraphicsSceneContextMenu:
3264 n = "GraphicsSceneContextMenu";
3266 case QEvent::GraphicsSceneHoverEnter:
3267 n = "GraphicsSceneHoverEnter";
3269 case QEvent::GraphicsSceneHoverMove:
3270 n = "GraphicsSceneHoverMove";
3272 case QEvent::GraphicsSceneHoverLeave:
3273 n = "GraphicsSceneHoverLeave";
3275 case QEvent::GraphicsSceneHelp:
3276 n = "GraphicsSceneHelp";
3278 case QEvent::GraphicsSceneDragEnter:
3279 n = "GraphicsSceneDragEnter";
3281 case QEvent::GraphicsSceneDragMove:
3282 n = "GraphicsSceneDragMove";
3284 case QEvent::GraphicsSceneDragLeave:
3285 n = "GraphicsSceneDragLeave";
3287 case QEvent::GraphicsSceneDrop:
3288 n = "GraphicsSceneDrop";
3290 case QEvent::GraphicsSceneWheel:
3291 n = "GraphicsSceneWheel";
3293 case QEvent::GraphicsSceneResize:
3294 n = "GraphicsSceneResize";
3296 case QEvent::GraphicsSceneMove:
3297 n = "GraphicsSceneMove";
3299 case QEvent::CursorChange:
3302 case QEvent::ToolTipChange:
3303 n = "ToolTipChange";
3305 case QEvent::StatusTip:
3308 case QEvent::WhatsThis:
3311 case QEvent::FontChange:
3317 case QEvent::KeyboardLayoutChange:
3318 n = "KeyboardLayoutChange";
3320 case QEvent::DynamicPropertyChange:
3321 n = "DynamicPropertyChange";
3323 case QEvent::GrabMouse:
3326 case QEvent::UngrabMouse:
3329 case QEvent::GrabKeyboard:
3332 case QEvent::UngrabKeyboard:
3333 n = "UngrabKeyboard";
3335 case QEvent::ChildAdded: n = n ? n : "ChildAdded";
3336 case QEvent::ChildPolished: n = n ? n : "ChildPolished";
3337 case QEvent::ChildRemoved: n = n ? n : "ChildRemoved";
3338 dbg.nospace() << "QChildEvent(" << n << ", " << (static_cast<const QChildEvent*>(e))->child();
3340 #ifndef QT_NO_GESTURES
3341 case QEvent::Gesture:
3346 dbg.nospace() << "QEvent(" << (const void *)e << ", type = " << e->type() << ')';
3350 dbg.nospace() << 'Q' << n << "Event(" << (const void *)e << ')';
3356 \class QShortcutEvent
3357 \brief The QShortcutEvent class provides an event which is generated when
3358 the user presses a key combination.
3363 Normally you don't need to use this class directly; QShortcut
3364 provides a higher-level interface to handle shortcut keys.
3370 \fn const QKeySequence &QShortcutEvent::key() const
3372 Returns the key sequence that triggered the event.
3376 \fn int QShortcutEvent::shortcutId() const
3378 Returns the ID of the QShortcut object for which this event was
3385 \fn bool QShortcutEvent::isAmbiguous() const
3387 Returns true if the key sequence that triggered the event is
3390 \sa QShortcut::activatedAmbiguously()
3394 \class QWindowStateChangeEvent
3398 \brief The QWindowStateChangeEvent class provides the window state before a
3399 window state change.
3402 /*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
3404 Returns the state of the window before the change.
3409 QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
3410 : QEvent(WindowStateChange), ostate(s), m_override(isOverride)
3416 bool QWindowStateChangeEvent::isOverride() const
3423 QWindowStateChangeEvent::~QWindowStateChangeEvent()
3430 \brief The QTouchEvent class contains parameters that describe a touch event.
3436 \section1 Enabling Touch Events
3438 Touch events occur when pressing, releasing, or moving one or more touch points on a touch
3439 device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
3440 Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
3441 \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
3443 When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouchEvents
3444 attribute on the scroll area's \l{QAbstractScrollArea::viewport()}{viewport}.
3446 Similarly to QMouseEvent, Qt automatically grabs each touch point on the first press inside a
3447 widget, and the widget will receive all updates for the touch point until it is released.
3448 Note that it is possible for a widget to receive events for numerous touch points, and that
3449 multiple widgets may be receiving touch events at the same time.
3451 \section1 Event Handling
3453 All touch events are of type QEvent::TouchBegin, QEvent::TouchUpdate, QEvent::TouchEnd or
3454 QEvent::TouchCancel. Reimplement QWidget::event() or QAbstractScrollArea::viewportEvent() for
3455 widgets and QGraphicsItem::sceneEvent() for items in a graphics view to receive touch events.
3457 Unlike widgets, QWindows receive touch events always, there is no need to opt in. When working
3458 directly with a QWindow, it is enough to reimplement QWindow::touchEvent().
3460 The QEvent::TouchUpdate and QEvent::TouchEnd events are sent to the widget or item that
3461 accepted the QEvent::TouchBegin event. If the QEvent::TouchBegin event is not accepted and not
3462 filtered by an event filter, then no further touch events are sent until the next
3465 Some systems may send an event of type QEvent::TouchCancel. Upon receiving this event
3466 applications are requested to ignore the entire active touch sequence. For example in a
3467 composited system the compositor may decide to treat certain gestures as system-wide
3468 gestures. Whenever such a decision is made (the gesture is recognized), the clients will be
3469 notified with a QEvent::TouchCancel event so they can update their state accordingly.
3471 The touchPoints() function returns a list of all touch points contained in the event. Note that
3472 this list may be empty, for example in case of a QEvent::TouchCancel event. Information about
3473 each touch point can be retrieved using the QTouchEvent::TouchPoint class. The
3474 Qt::TouchPointState enum describes the different states that a touch point may have.
3476 \note The list of touchPoints() will never be partial: A touch event will always contain a touch
3477 point for each existing physical touch contacts targetting the window or widget to which the
3478 event is sent. For instance, assuming that all touches target the same window or widget, an
3479 event with a condition of touchPoints().count()==2 is guaranteed to imply that the number of
3480 fingers touching the touchscreen or touchpad is exactly two.
3482 \section1 Event Delivery and Propagation
3484 By default, QGuiApplication translates the first touch point in a QTouchEvent into
3485 a QMouseEvent. This makes it possible to enable touch events on existing widgets that do not
3486 normally handle QTouchEvent. See below for information on some special considerations needed
3489 QEvent::TouchBegin is the first touch event sent to a widget. The QEvent::TouchBegin event
3490 contains a special accept flag that indicates whether the receiver wants the event. By default,
3491 the event is accepted. You should call ignore() if the touch event is not handled by your
3492 widget. The QEvent::TouchBegin event is propagated up the parent widget chain until a widget
3493 accepts it with accept(), or an event filter consumes it. For QGraphicsItems, the
3494 QEvent::TouchBegin event is propagated to items under the mouse (similar to mouse event
3495 propagation for QGraphicsItems).
3497 \section1 Touch Point Grouping
3499 As mentioned above, it is possible that several widgets can be receiving QTouchEvents at the
3500 same time. However, Qt makes sure to never send duplicate QEvent::TouchBegin events to the same
3501 widget, which could theoretically happen during propagation if, for example, the user touched 2
3502 separate widgets in a QGroupBox and both widgets ignored the QEvent::TouchBegin event.
3504 To avoid this, Qt will group new touch points together using the following rules:
3508 \li When the first touch point is detected, the destination widget is determined firstly by the
3509 location on screen and secondly by the propagation rules.
3511 \li When additional touch points are detected, Qt first looks to see if there are any active
3512 touch points on any ancestor or descendent of the widget under the new touch point. If there
3513 are, the new touch point is grouped with the first, and the new touch point will be sent in a
3514 single QTouchEvent to the widget that handled the first touch point. (The widget under the new
3515 touch point will not receive an event).
3519 This makes it possible for sibling widgets to handle touch events independently while making
3520 sure that the sequence of QTouchEvents is always correct.
3522 \section1 Mouse Events and Touch Event synthesizing
3524 QTouchEvent delivery is independent from that of QMouseEvent. The application flags
3525 Qt::AA_SynthesizeTouchForUnhandledMouseEvents and Qt::AA_SynthesizeMouseForUnhandledTouchEvents
3526 can be used to enable or disable automatic synthesizing of touch events to mouse events and
3527 mouse events to touch events.
3533 \li As mentioned above, enabling touch events means multiple widgets can be receiving touch
3534 events simultaneously. Combined with the default QWidget::event() handling for QTouchEvents,
3535 this gives you great flexibility in designing touch user interfaces. Be aware of the
3536 implications. For example, it is possible that the user is moving a QSlider with one finger and
3537 pressing a QPushButton with another. The signals emitted by these widgets will be
3540 \li Recursion into the event loop using one of the exec() methods (e.g., QDialog::exec() or
3541 QMenu::exec()) in a QTouchEvent event handler is not supported. Since there are multiple event
3542 recipients, recursion may cause problems, including but not limited to lost events
3543 and unexpected infinite recursion.
3545 \li QTouchEvents are not affected by a \l{QWidget::grabMouse()}{mouse grab} or an
3546 \l{QApplication::activePopupWidget()}{active pop-up widget}. The behavior of QTouchEvents is
3547 undefined when opening a pop-up or grabbing the mouse while there are more than one active touch
3552 \sa QTouchEvent::TouchPoint, Qt::TouchPointState, Qt::WA_AcceptTouchEvents,
3553 QGraphicsItem::acceptTouchEvents()
3556 /*! \enum QTouchEvent::DeviceType
3559 This enum represents the type of device that generated a QTouchEvent.
3561 This enum has been deprecated. Use QTouchDevice::DeviceType instead.
3563 \omitvalue TouchScreen
3565 \sa QTouchDevice::DeviceType, QTouchDevice::type(), QTouchEvent::device()
3569 Constructs a QTouchEvent with the given \a eventType, \a device, and
3570 \a touchPoints. The \a touchPointStates and \a modifiers
3571 are the current touch point states and keyboard modifiers at the time of
3574 QTouchEvent::QTouchEvent(QEvent::Type eventType,
3575 QTouchDevice *device,
3576 Qt::KeyboardModifiers modifiers,
3577 Qt::TouchPointStates touchPointStates,
3578 const QList<QTouchEvent::TouchPoint> &touchPoints)
3579 : QInputEvent(eventType, modifiers),
3583 _touchPointStates(touchPointStates),
3584 _touchPoints(touchPoints)
3588 Destroys the QTouchEvent.
3590 QTouchEvent::~QTouchEvent()
3593 /*! \fn QWindow *QTouchEvent::window() const
3595 Returns the window on which the event occurred. Useful for doing
3596 global-local mapping on data like rawScreenPositions() which,
3597 for performance reasons, only stores the global positions in the
3601 /*! \fn QObject *QTouchEvent::target() const
3603 Returns the target object within the window on which the event occurred.
3604 This is typically a QWidget or a QQuickItem. May be 0 when no specific target is available.
3607 /*! \fn QTouchEvent::DeviceType QTouchEvent::deviceType() const
3610 Returns the touch device Type, which is of type \l {QTouchEvent::DeviceType} {DeviceType}.
3612 This function has been deprecated. Use QTouchDevice::type() instead.
3614 \sa QTouchDevice::type(), QTouchEvent::device()
3617 /*! \fn Qt::TouchPointStates QTouchEvent::touchPointStates() const
3619 Returns a bitwise OR of all the touch point states for this event.
3622 /*! \fn const QList<QTouchEvent::TouchPoint> &QTouchEvent::touchPoints() const
3624 Returns the list of touch points contained in the touch event.
3627 /*! \fn QTouchDevice* QTouchEvent::device() const
3629 Returns the touch device from which this touch event originates.
3632 /*! \fn void QTouchEvent::setWindow(QWindow *window)
3636 Sets the window for this event.
3639 /*! \fn void QTouchEvent::setTarget(QObject *target)
3643 Sets the target within the window (typically a widget) for this event.
3646 /*! \fn void QTouchEvent::setTouchPointStates(Qt::TouchPointStates touchPointStates)
3650 Sets a bitwise OR of all the touch point states for this event.
3653 /*! \fn void QTouchEvent::setTouchPoints(const QList<QTouchEvent::TouchPoint> &touchPoints)
3657 Sets the list of touch points for this event.
3660 /*! \fn void QTouchEvent::setDevice(QTouchDevice *adevice)
3664 Sets the device to \a adevice.
3667 /*! \class QTouchEvent::TouchPoint
3668 \brief The TouchPoint class provides information about a touch point in a QTouchEvent.
3673 /*! \enum TouchPoint::InfoFlag
3675 The values of this enum describe additional information about a touch point.
3677 \value Pen Indicates that the contact has been made by a designated pointing device (e.g. a pen) instead of a finger.
3683 Constructs a QTouchEvent::TouchPoint for use in a QTouchEvent.
3685 QTouchEvent::TouchPoint::TouchPoint(int id)
3686 : d(new QTouchEventTouchPointPrivate(id))
3690 \fn TouchPoint::TouchPoint(const TouchPoint &other)
3693 Constructs a copy of \a other.
3695 QTouchEvent::TouchPoint::TouchPoint(const QTouchEvent::TouchPoint &other)
3704 Destroys the QTouchEvent::TouchPoint.
3706 QTouchEvent::TouchPoint::~TouchPoint()
3708 if (d && !d->ref.deref())
3713 Returns the id number of this touch point.
3715 Do not assume that id numbers start at zero or that they are sequential.
3716 Such an assumption is often false due to the way the underlying drivers work.
3718 int QTouchEvent::TouchPoint::id() const
3724 Returns the current state of this touch point.
3726 Qt::TouchPointState QTouchEvent::TouchPoint::state() const
3728 return Qt::TouchPointState(int(d->state));
3732 Returns the position of this touch point, relative to the widget
3733 or QGraphicsItem that received the event.
3735 \sa startPos(), lastPos(), screenPos(), scenePos(), normalizedPos()
3737 QPointF QTouchEvent::TouchPoint::pos() const
3739 return d->rect.center();
3743 Returns the scene position of this touch point.
3745 The scene position is the position in QGraphicsScene coordinates
3746 if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3747 reimplementation, and identical to the screen position for
3750 \sa startScenePos(), lastScenePos(), pos()
3752 QPointF QTouchEvent::TouchPoint::scenePos() const
3754 return d->sceneRect.center();
3758 Returns the screen position of this touch point.
3760 \sa startScreenPos(), lastScreenPos(), pos()
3762 QPointF QTouchEvent::TouchPoint::screenPos() const
3764 return d->screenRect.center();
3768 Returns the normalized position of this touch point.
3770 The coordinates are normalized to the size of the touch device,
3771 i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3773 \sa startNormalizedPos(), lastNormalizedPos(), pos()
3775 QPointF QTouchEvent::TouchPoint::normalizedPos() const
3777 return d->normalizedPos;
3781 Returns the starting position of this touch point, relative to the
3782 widget or QGraphicsItem that received the event.
3784 \sa pos(), lastPos()
3786 QPointF QTouchEvent::TouchPoint::startPos() const
3792 Returns the starting scene position of this touch point.
3794 The scene position is the position in QGraphicsScene coordinates
3795 if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3796 reimplementation, and identical to the screen position for
3799 \sa scenePos(), lastScenePos()
3801 QPointF QTouchEvent::TouchPoint::startScenePos() const
3803 return d->startScenePos;
3807 Returns the starting screen position of this touch point.
3809 \sa screenPos(), lastScreenPos()
3811 QPointF QTouchEvent::TouchPoint::startScreenPos() const
3813 return d->startScreenPos;
3817 Returns the normalized starting position of this touch point.
3819 The coordinates are normalized to the size of the touch device,
3820 i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3822 \sa normalizedPos(), lastNormalizedPos()
3824 QPointF QTouchEvent::TouchPoint::startNormalizedPos() const
3826 return d->startNormalizedPos;
3830 Returns the position of this touch point from the previous touch
3831 event, relative to the widget or QGraphicsItem that received the event.
3833 \sa pos(), startPos()
3835 QPointF QTouchEvent::TouchPoint::lastPos() const
3841 Returns the scene position of this touch point from the previous
3844 The scene position is the position in QGraphicsScene coordinates
3845 if the QTouchEvent is handled by a QGraphicsItem::touchEvent()
3846 reimplementation, and identical to the screen position for
3849 \sa scenePos(), startScenePos()
3851 QPointF QTouchEvent::TouchPoint::lastScenePos() const
3853 return d->lastScenePos;
3857 Returns the screen position of this touch point from the previous
3860 \sa screenPos(), startScreenPos()
3862 QPointF QTouchEvent::TouchPoint::lastScreenPos() const
3864 return d->lastScreenPos;
3868 Returns the normalized position of this touch point from the
3869 previous touch event.
3871 The coordinates are normalized to the size of the touch device,
3872 i.e. (0,0) is the top-left corner and (1,1) is the bottom-right corner.
3874 \sa normalizedPos(), startNormalizedPos()
3876 QPointF QTouchEvent::TouchPoint::lastNormalizedPos() const
3878 return d->lastNormalizedPos;
3882 Returns the rect for this touch point, relative to the widget
3883 or QGraphicsItem that received the event. The rect is centered
3884 around the point returned by pos().
3886 \note This function returns an empty rect if the device does not report touch point sizes.
3888 QRectF QTouchEvent::TouchPoint::rect() const
3894 Returns the rect for this touch point in scene coordinates.
3896 \note This function returns an empty rect if the device does not report touch point sizes.
3898 \sa scenePos(), rect()
3900 QRectF QTouchEvent::TouchPoint::sceneRect() const
3902 return d->sceneRect;
3906 Returns the rect for this touch point in screen coordinates.
3908 \note This function returns an empty rect if the device does not report touch point sizes.
3910 \sa screenPos(), rect()
3912 QRectF QTouchEvent::TouchPoint::screenRect() const
3914 return d->screenRect;
3918 Returns the pressure of this touch point. The return value is in
3919 the range 0.0 to 1.0.
3921 qreal QTouchEvent::TouchPoint::pressure() const
3927 Returns a velocity vector for this touch point.
3928 The vector is in the screen's coordinate system, using pixels per seconds for the magnitude.
3930 \note The returned vector is only valid if the touch device's capabilities include QTouchDevice::Velocity.
3932 \sa QTouchDevice::capabilities(), device()
3934 QVector2D QTouchEvent::TouchPoint::velocity() const
3940 Returns additional information about the touch point.
3942 \sa QTouchEvent::TouchPoint::InfoFlags
3944 QTouchEvent::TouchPoint::InfoFlags QTouchEvent::TouchPoint::flags() const
3951 Returns the raw, unfiltered positions for the touch point. The positions are in native screen coordinates.
3952 To get local coordinates you can use mapFromGlobal() of the QWindow returned by QTouchEvent::window().
3954 \note Returns an empty vector if the touch device's capabilities do not include QTouchDevice::RawPositions.
3956 \note Native screen coordinates refer to the native orientation of the screen which, in case of
3957 mobile devices, is typically portrait. This means that on systems capable of screen orientation
3958 changes the positions in this list will not reflect the current orientation (unlike pos(),
3959 screenPos(), etc.) and will always be reported in the native orientation.
3961 \sa QTouchDevice::capabilities(), device(), window()
3963 QVector<QPointF> QTouchEvent::TouchPoint::rawScreenPositions() const
3965 return d->rawScreenPositions;
3969 void QTouchEvent::TouchPoint::setId(int id)
3971 if (d->ref.load() != 1)
3977 void QTouchEvent::TouchPoint::setState(Qt::TouchPointStates state)
3979 if (d->ref.load() != 1)
3985 void QTouchEvent::TouchPoint::setPos(const QPointF &pos)
3987 if (d->ref.load() != 1)
3989 d->rect.moveCenter(pos);
3993 void QTouchEvent::TouchPoint::setScenePos(const QPointF &scenePos)
3995 if (d->ref.load() != 1)
3997 d->sceneRect.moveCenter(scenePos);
4001 void QTouchEvent::TouchPoint::setScreenPos(const QPointF &screenPos)
4003 if (d->ref.load() != 1)
4005 d->screenRect.moveCenter(screenPos);
4009 void QTouchEvent::TouchPoint::setNormalizedPos(const QPointF &normalizedPos)
4011 if (d->ref.load() != 1)
4013 d->normalizedPos = normalizedPos;
4017 void QTouchEvent::TouchPoint::setStartPos(const QPointF &startPos)
4019 if (d->ref.load() != 1)
4021 d->startPos = startPos;
4025 void QTouchEvent::TouchPoint::setStartScenePos(const QPointF &startScenePos)
4027 if (d->ref.load() != 1)
4029 d->startScenePos = startScenePos;
4033 void QTouchEvent::TouchPoint::setStartScreenPos(const QPointF &startScreenPos)
4035 if (d->ref.load() != 1)
4037 d->startScreenPos = startScreenPos;
4041 void QTouchEvent::TouchPoint::setStartNormalizedPos(const QPointF &startNormalizedPos)
4043 if (d->ref.load() != 1)
4045 d->startNormalizedPos = startNormalizedPos;
4049 void QTouchEvent::TouchPoint::setLastPos(const QPointF &lastPos)
4051 if (d->ref.load() != 1)
4053 d->lastPos = lastPos;
4057 void QTouchEvent::TouchPoint::setLastScenePos(const QPointF &lastScenePos)
4059 if (d->ref.load() != 1)
4061 d->lastScenePos = lastScenePos;
4065 void QTouchEvent::TouchPoint::setLastScreenPos(const QPointF &lastScreenPos)
4067 if (d->ref.load() != 1)
4069 d->lastScreenPos = lastScreenPos;
4073 void QTouchEvent::TouchPoint::setLastNormalizedPos(const QPointF &lastNormalizedPos)
4075 if (d->ref.load() != 1)
4077 d->lastNormalizedPos = lastNormalizedPos;
4081 void QTouchEvent::TouchPoint::setRect(const QRectF &rect)
4083 if (d->ref.load() != 1)
4089 void QTouchEvent::TouchPoint::setSceneRect(const QRectF &sceneRect)
4091 if (d->ref.load() != 1)
4093 d->sceneRect = sceneRect;
4097 void QTouchEvent::TouchPoint::setScreenRect(const QRectF &screenRect)
4099 if (d->ref.load() != 1)
4101 d->screenRect = screenRect;
4105 void QTouchEvent::TouchPoint::setPressure(qreal pressure)
4107 if (d->ref.load() != 1)
4109 d->pressure = pressure;
4113 void QTouchEvent::TouchPoint::setVelocity(const QVector2D &v)
4115 if (d->ref.load() != 1)
4121 void QTouchEvent::TouchPoint::setRawScreenPositions(const QVector<QPointF> &positions)
4123 if (d->ref.load() != 1)
4125 d->rawScreenPositions = positions;
4131 void QTouchEvent::TouchPoint::setFlags(InfoFlags flags)
4133 if (d->ref.load() != 1)
4139 \fn TouchPoint &TouchPoint::operator=(const TouchPoint &other)
4144 \fn void QTouchEvent::TouchPoint::swap(TouchPoint &other);
4149 \class QScrollPrepareEvent
4154 \brief The QScrollPrepareEvent class is send in preparation of a scrolling.
4156 The scroll prepare event is send before scrolling (usually by QScroller) is started.
4157 The object receiving this event should set viewportSize, maxContentPos and contentPos.
4158 It also should accept this event to indicate that scrolling should be started.
4160 It is not guaranteed that a QScrollEvent will be send after an acceepted
4161 QScrollPrepareEvent, e.g. in a case where the maximum content position is (0,0).
4163 \sa QScrollEvent, QScroller
4167 Creates new QScrollPrepareEvent
4168 The \a startPos is the position of a touch or mouse event that started the scrolling.
4170 QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos)
4171 : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos)
4176 Destroys QScrollEvent.
4178 QScrollPrepareEvent::~QScrollPrepareEvent()
4183 Returns the position of the touch or mouse event that started the scrolling.
4185 QPointF QScrollPrepareEvent::startPos() const
4191 Returns size of the area that is to be scrolled as set by setViewportSize
4193 \sa setViewportSize()
4195 QSizeF QScrollPrepareEvent::viewportSize() const
4197 return m_viewportSize;
4201 Returns the range of coordinates for the content as set by setContentPosRange().
4203 QRectF QScrollPrepareEvent::contentPosRange() const
4205 return m_contentPosRange;
4209 Returns the current position of the content as set by setContentPos.
4211 QPointF QScrollPrepareEvent::contentPos() const
4213 return m_contentPos;
4218 Sets the size of the area that is to be scrolled to \a size.
4222 void QScrollPrepareEvent::setViewportSize(const QSizeF &size)
4224 m_viewportSize = size;
4228 Sets the range of content coordinates to \a rect.
4230 \sa contentPosRange()
4232 void QScrollPrepareEvent::setContentPosRange(const QRectF &rect)
4234 m_contentPosRange = rect;
4238 Sets the current content position to \a pos.
4242 void QScrollPrepareEvent::setContentPos(const QPointF &pos)
4254 \brief The QScrollEvent class is send when scrolling.
4256 The scroll event is send to indicate that the receiver should be scrolled.
4257 Usually the receiver should be something visual like QWidget or QGraphicsObject.
4259 Some care should be taken that no conflicting QScrollEvents are sent from two
4260 sources. Using QScroller::scrollTo is save however.
4262 \sa QScrollPrepareEvent, QScroller
4266 \enum QScrollEvent::ScrollState
4268 This enum describes the states a scroll event can have.
4270 \value ScrollStarted Set for the first scroll event of a scroll activity.
4272 \value ScrollUpdated Set for all but the first and the last scroll event of a scroll activity.
4274 \value ScrollFinished Set for the last scroll event of a scroll activity.
4276 \sa QScrollEvent::scrollState()
4280 Creates a new QScrollEvent
4281 \a contentPos is the new content position, \a overshootDistance is the
4282 new overshoot distance while \a scrollState indicates if this scroll
4283 event is the first one, the last one or some event in between.
4285 QScrollEvent::QScrollEvent(const QPointF &contentPos, const QPointF &overshootDistance, ScrollState scrollState)
4286 : QEvent(QEvent::Scroll), m_contentPos(contentPos), m_overshoot(overshootDistance), m_state(scrollState)
4291 Destroys QScrollEvent.
4293 QScrollEvent::~QScrollEvent()
4298 Returns the new scroll position.
4300 QPointF QScrollEvent::contentPos() const
4302 return m_contentPos;
4306 Returns the new overshoot distance.
4307 See QScroller for an explanation of the term overshoot.
4311 QPointF QScrollEvent::overshootDistance() const
4317 Returns the current scroll state as a combination of ScrollStateFlag values.
4318 ScrollStarted (or ScrollFinished) will be set, if this scroll event is the first (or last) event in a scrolling activity.
4319 Please note that both values can be set at the same time, if the activity consists of a single QScrollEvent.
4320 All other scroll events in between will have their state set to ScrollUpdated.
4322 A widget could for example revert selections when scrolling is started and stopped.
4324 QScrollEvent::ScrollState QScrollEvent::scrollState() const
4330 Creates a new QScreenOrientationChangeEvent
4331 \a orientation is the new orientation of the screen.
4333 QScreenOrientationChangeEvent::QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation screenOrientation)
4334 : QEvent(QEvent::OrientationChange), m_screen(screen), m_orientation(screenOrientation)
4339 Destroys QScreenOrientationChangeEvent.
4341 QScreenOrientationChangeEvent::~QScreenOrientationChangeEvent()
4346 Returns the screen whose orientation changed.
4348 QScreen *QScreenOrientationChangeEvent::screen() const
4354 Returns the orientation of the screen.
4356 Qt::ScreenOrientation QScreenOrientationChangeEvent::orientation() const
4358 return m_orientation;