1 /****************************************************************************
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
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 The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/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 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file. Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
40 ****************************************************************************/
44 #include "qapplication.h"
45 #include "private/qapplication_p.h"
46 #include "private/qevent_p.h"
47 #include "private/qkeysequence_p.h"
49 #include "qgraphicsview.h"
55 #include "qgesture_p.h"
58 #include "private/qcore_symbian_p.h"
67 \brief The QInputEvent class is the base class for events that
74 QInputEvent::QInputEvent(Type type, Qt::KeyboardModifiers modifiers)
75 : QEvent(type), modState(modifiers)
81 QInputEvent::~QInputEvent()
86 \fn Qt::KeyboardModifiers QInputEvent::modifiers() const
88 Returns the keyboard modifier flags that existed immediately
89 before the event occurred.
91 \sa QApplication::keyboardModifiers()
94 /*! \fn void QInputEvent::setModifiers(Qt::KeyboardModifiers modifiers)
98 Sets the keyboard modifiers flags for this event.
105 \brief The QMouseEvent class contains parameters that describe a mouse event.
107 Mouse events occur when a mouse button is pressed or released
108 inside a widget, or when the mouse cursor is moved.
110 Mouse move events will occur only when a mouse button is pressed
111 down, unless mouse tracking has been enabled with
112 QWidget::setMouseTracking().
114 Qt automatically grabs the mouse when a mouse button is pressed
115 inside a widget; the widget will continue to receive mouse events
116 until the last mouse button is released.
118 A mouse event contains a special accept flag that indicates
119 whether the receiver wants the event. You should call ignore() if
120 the mouse event is not handled by your widget. A mouse event is
121 propagated up the parent widget chain until a widget accepts it
122 with accept(), or an event filter consumes it.
124 \note If a mouse event is propagated to a \l{QWidget}{widget} for
125 which Qt::WA_NoMousePropagation has been set, that mouse event
126 will not be propagated further up the parent widget chain.
128 The state of the keyboard modifier keys can be found by calling the
129 \l{QInputEvent::modifiers()}{modifiers()} function, inherited from
132 The functions pos(), x(), and y() give the cursor position
133 relative to the widget that receives the mouse event. If you
134 move the widget as a result of the mouse event, use the global
135 position returned by globalPos() to avoid a shaking motion.
137 The QWidget::setEnabled() function can be used to enable or
138 disable mouse and keyboard events for a widget.
140 Reimplement the QWidget event handlers, QWidget::mousePressEvent(),
141 QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(),
142 and QWidget::mouseMoveEvent() to receive mouse events in your own
145 \sa QWidget::setMouseTracking() QWidget::grabMouse() QCursor::pos()
149 Constructs a mouse event object.
151 The \a type parameter must be one of QEvent::MouseButtonPress,
152 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
153 or QEvent::MouseMove.
155 The \a position is the mouse cursor's position relative to the
157 The \a button that caused the event is given as a value from
158 the Qt::MouseButton enum. If the event \a type is
159 \l MouseMove, the appropriate button for this event is Qt::NoButton.
160 The mouse and keyboard states at the time of the event are specified by
161 \a buttons and \a modifiers.
163 The globalPos() is initialized to QCursor::pos(), which may not
164 be appropriate. Use the other constructor to specify the global
168 QMouseEvent::QMouseEvent(Type type, const QPoint &position, Qt::MouseButton button,
169 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
170 : QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
178 QMouseEvent::~QMouseEvent()
184 Use QMouseEvent(\a type, \a pos, \a button, \c buttons, \c
185 modifiers) instead, where \c buttons is \a state &
186 Qt::MouseButtonMask and \c modifiers is \a state &
189 QMouseEvent::QMouseEvent(Type type, const QPoint &pos, Qt::ButtonState button, int state)
190 : QInputEvent(type), p(pos), b((Qt::MouseButton)button)
193 mouseState = Qt::MouseButtons((state ^ b) & Qt::MouseButtonMask);
194 modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
198 Use QMouseEvent(\a type, \a pos, \a globalPos, \a button,
199 \c buttons, \c modifiers) instead, where
200 \c buttons is \a state & Qt::MouseButtonMask and
201 \c modifiers is \a state & Qt::KeyButtonMask.
203 QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
204 Qt::ButtonState button, int state)
205 : QInputEvent(type), p(pos), g(globalPos), b((Qt::MouseButton)button)
207 mouseState = Qt::MouseButtons((state ^ b) & Qt::MouseButtonMask);
208 modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
214 Constructs a mouse event object.
216 The \a type parameter must be QEvent::MouseButtonPress,
217 QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick,
218 or QEvent::MouseMove.
220 The \a pos is the mouse cursor's position relative to the
221 receiving widget. The cursor's position in global coordinates is
222 specified by \a globalPos. The \a button that caused the event is
223 given as a value from the \l Qt::MouseButton enum. If the event \a
224 type is \l MouseMove, the appropriate button for this event is
225 Qt::NoButton. \a buttons is the state of all buttons at the
226 time of the event, \a modifiers the state of all keyboard
230 QMouseEvent::QMouseEvent(Type type, const QPoint &pos, const QPoint &globalPos,
231 Qt::MouseButton button, Qt::MouseButtons buttons,
232 Qt::KeyboardModifiers modifiers)
233 : QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
239 QMouseEvent *QMouseEvent::createExtendedMouseEvent(Type type, const QPointF &pos,
240 const QPoint &globalPos, Qt::MouseButton button,
241 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
243 return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
247 \fn bool QMouseEvent::hasExtendedInfo() const
254 Returns the position of the mouse cursor as a QPointF, relative to the
255 widget that received the event.
257 If you move the widget as a result of the mouse event, use the
258 global position returned by globalPos() to avoid a shaking
261 \sa x() y() pos() globalPos()
263 QPointF QMouseEvent::posF() const
265 return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
271 QMouseEventEx::QMouseEventEx(Type type, const QPointF &pos, const QPoint &globalPos,
272 Qt::MouseButton button, Qt::MouseButtons buttons,
273 Qt::KeyboardModifiers modifiers)
274 : QMouseEvent(type, pos.toPoint(), globalPos, button, buttons, modifiers), posF(pos)
276 d = reinterpret_cast<QEventPrivate *>(this);
282 QMouseEventEx::~QMouseEventEx()
287 \fn const QPoint &QMouseEvent::pos() const
289 Returns the position of the mouse cursor, relative to the widget
290 that received the event.
292 If you move the widget as a result of the mouse event, use the
293 global position returned by globalPos() to avoid a shaking
296 \sa x() y() globalPos()
300 \fn const QPoint &QMouseEvent::globalPos() const
302 Returns the global position of the mouse cursor \e{at the time
303 of the event}. This is important on asynchronous window systems
304 like X11. Whenever you move your widgets around in response to
305 mouse events, globalPos() may differ a lot from the current
306 pointer position QCursor::pos(), and from
307 QWidget::mapToGlobal(pos()).
309 \sa globalX() globalY()
313 \fn int QMouseEvent::x() const
315 Returns the x position of the mouse cursor, relative to the
316 widget that received the event.
322 \fn int QMouseEvent::y() const
324 Returns the y position of the mouse cursor, relative to the
325 widget that received the event.
331 \fn int QMouseEvent::globalX() const
333 Returns the global x position of the mouse cursor at the time of
336 \sa globalY() globalPos()
340 \fn int QMouseEvent::globalY() const
342 Returns the global y position of the mouse cursor at the time of
345 \sa globalX() globalPos()
349 \fn Qt::MouseButton QMouseEvent::button() const
351 Returns the button that caused the event.
353 Note that the returned value is always Qt::NoButton for mouse
356 \sa buttons() Qt::MouseButton
360 \fn Qt::MouseButton QMouseEvent::buttons() const
362 Returns the button state when the event was generated. The button
363 state is a combination of Qt::LeftButton, Qt::RightButton,
364 Qt::MidButton using the OR operator. For mouse move events,
365 this is all buttons that are pressed down. For mouse press and
366 double click events this includes the button that caused the
367 event. For mouse release events this excludes the button that
370 \sa button() Qt::MouseButton
375 \fn Qt::ButtonState QMouseEvent::state() const
377 Returns the button state immediately before the event was
378 generated. The button state is a combination of mouse buttons
379 (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
381 Use buttons() and/or modifiers() instead. Be aware that buttons()
382 return the state immediately \e after the event was generated.
386 \fn Qt::ButtonState QMouseEvent::stateAfter() const
388 Returns the button state immediately after the event was
389 generated. The button state is a combination of mouse buttons
390 (see Qt::ButtonState) and keyboard modifiers (Qt::MouseButtons).
392 Use buttons() and/or modifiers() instead.
399 \brief The QHoverEvent class contains parameters that describe a mouse event.
401 Mouse events occur when a mouse cursor is moved into, out of, or within a
402 widget, and if the widget has the Qt::WA_Hover attribute.
404 The function pos() gives the current cursor position, while oldPos() gives
405 the old mouse position.
407 There are a few similarities between the events QEvent::HoverEnter
408 and QEvent::HoverLeave, and the events QEvent::Enter and QEvent::Leave.
409 However, they are slightly different because we do an update() in the event
410 handler of HoverEnter and HoverLeave.
412 QEvent::HoverMove is also slightly different from QEvent::MouseMove. Let us
413 consider a top-level window A containing a child B which in turn contains a
414 child C (all with mouse tracking enabled):
416 \image hoverevents.png
418 Now, if you move the cursor from the top to the bottom in the middle of A,
419 you will get the following QEvent::MouseMove events:
427 You will get the same events for QEvent::HoverMove, except that the event
428 always propagates to the top-level regardless whether the event is accepted
429 or not. It will only stop propagating with the Qt::WA_NoMousePropagation
432 In this case the events will occur in the following way:
436 \o A::HoverMove, B::HoverMove
437 \o A::HoverMove, B::HoverMove, C::HoverMove
443 \fn const QPoint &QHoverEvent::pos() const
445 Returns the position of the mouse cursor, relative to the widget
446 that received the event.
448 On QEvent::HoverLeave events, this position will always be
455 \fn const QPoint &QHoverEvent::oldPos() const
457 Returns the previous position of the mouse cursor, relative to the widget
458 that received the event. If there is no previous position, oldPos() will
459 return the same position as pos().
461 On QEvent::HoverEnter events, this position will always be
468 Constructs a hover event object.
470 The \a type parameter must be QEvent::HoverEnter,
471 QEvent::HoverLeave, or QEvent::HoverMove.
473 The \a pos is the current mouse cursor's position relative to the
474 receiving widget, while \a oldPos is the previous mouse cursor's
475 position relative to the receiving widget.
477 QHoverEvent::QHoverEvent(Type type, const QPoint &pos, const QPoint &oldPos)
478 : QEvent(type), p(pos), op(oldPos)
485 QHoverEvent::~QHoverEvent()
492 \brief The QWheelEvent class contains parameters that describe a wheel event.
496 Wheel events are sent to the widget under the mouse cursor, but
497 if that widget does not handle the event they are sent to the
498 focus widget. The rotation distance is provided by delta().
499 The functions pos() and globalPos() return the mouse cursor's
500 location at the time of the event.
502 A wheel event contains a special accept flag that indicates
503 whether the receiver wants the event. You should call ignore() if
504 you do not handle the wheel event; this ensures that it will be
505 sent to the parent widget.
507 The QWidget::setEnabled() function can be used to enable or
508 disable mouse and keyboard events for a widget.
510 The event handler QWidget::wheelEvent() receives wheel events.
512 \sa QMouseEvent QWidget::grabMouse()
516 \fn Qt::MouseButtons QWheelEvent::buttons() const
518 Returns the mouse state when the event occurred.
522 \fn Qt::Orientation QWheelEvent::orientation() const
524 Returns the wheel's orientation.
528 Constructs a wheel event object.
530 The position, \a pos, is the location of the mouse cursor within
531 the widget. The globalPos() is initialized to QCursor::pos()
532 which is usually, but not always, correct.
533 Use the other constructor if you need to specify the global
536 The \a buttons describe the state of the mouse buttons at the time
537 of the event, \a delta contains the rotation distance,
538 \a modifiers holds the keyboard modifier flags at the time of the
539 event, and \a orient holds the wheel's orientation.
541 \sa pos() delta() state()
543 #ifndef QT_NO_WHEELEVENT
544 QWheelEvent::QWheelEvent(const QPoint &pos, int delta,
545 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
546 Qt::Orientation orient)
547 : QInputEvent(Wheel, modifiers), p(pos), d(delta), mouseState(buttons), o(orient)
555 QWheelEvent::~QWheelEvent()
561 Use one of the other constructors instead.
563 QWheelEvent::QWheelEvent(const QPoint &pos, int delta, int state, Qt::Orientation orient)
564 : QInputEvent(Wheel), p(pos), d(delta), o(orient)
567 mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);
568 modState = Qt::KeyboardModifiers(state & (int)Qt::KeyButtonMask);
573 Constructs a wheel event object.
575 The \a pos provides the location of the mouse cursor
576 within the widget. The position in global coordinates is specified
577 by \a globalPos. \a delta contains the rotation distance, \a modifiers
578 holds the keyboard modifier flags at the time of the event, and
579 \a orient holds the wheel's orientation.
581 \sa pos() globalPos() delta() state()
583 QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta,
584 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers,
585 Qt::Orientation orient)
586 : QInputEvent(Wheel, modifiers), p(pos), g(globalPos), d(delta), mouseState(buttons), o(orient)
591 Use one of the other constructors instead.
593 QWheelEvent::QWheelEvent(const QPoint &pos, const QPoint& globalPos, int delta, int state,
594 Qt::Orientation orient)
595 : QInputEvent(Wheel), p(pos), g(globalPos), d(delta), o(orient)
597 mouseState = Qt::MouseButtons(state & Qt::MouseButtonMask);
598 modState = Qt::KeyboardModifiers(state & (int) Qt::KeyButtonMask);
601 #endif // QT_NO_WHEELEVENT
604 \fn int QWheelEvent::delta() const
606 Returns the distance that the wheel is rotated, in eighths of a
607 degree. A positive value indicates that the wheel was rotated
608 forwards away from the user; a negative value indicates that the
609 wheel was rotated backwards toward the user.
611 Most mouse types work in steps of 15 degrees, in which case the
612 delta value is a multiple of 120; i.e., 120 units * 1/8 = 15 degrees.
614 However, some mice have finer-resolution wheels and send delta values
615 that are less than 120 units (less than 15 degrees). To support this
616 possibility, you can either cumulatively add the delta values from events
617 until the value of 120 is reached, then scroll the widget, or you can
618 partially scroll the widget in response to each wheel event.
622 \snippet doc/src/snippets/code/src_gui_kernel_qevent.cpp 0
626 \fn const QPoint &QWheelEvent::pos() const
628 Returns the position of the mouse cursor relative to the widget
629 that received the event.
631 If you move your widgets around in response to mouse events,
632 use globalPos() instead of this function.
634 \sa x() y() globalPos()
638 \fn int QWheelEvent::x() const
640 Returns the x position of the mouse cursor, relative to the
641 widget that received the event.
647 \fn int QWheelEvent::y() const
649 Returns the y position of the mouse cursor, relative to the
650 widget that received the event.
657 \fn const QPoint &QWheelEvent::globalPos() const
659 Returns the global position of the mouse pointer \e{at the time
660 of the event}. This is important on asynchronous window systems
661 such as X11; whenever you move your widgets around in response to
662 mouse events, globalPos() can differ a lot from the current
663 cursor position returned by QCursor::pos().
665 \sa globalX() globalY()
669 \fn int QWheelEvent::globalX() const
671 Returns the global x position of the mouse cursor at the time of
674 \sa globalY() globalPos()
678 \fn int QWheelEvent::globalY() const
680 Returns the global y position of the mouse cursor at the time of
683 \sa globalX() globalPos()
688 \fn Qt::ButtonState QWheelEvent::state() const
690 Returns the keyboard modifier flags at the time of the event.
692 The returned value is a selection of the following values,
693 combined using the OR operator: Qt::ShiftButton,
694 Qt::ControlButton, and Qt::AltButton.
700 \brief The QKeyEvent class describes a key event.
704 Key events are sent to the widget with keyboard input focus
705 when keys are pressed or released.
707 A key event contains a special accept flag that indicates whether
708 the receiver will handle the key event. You should call ignore()
709 if the key press or release event is not handled by your widget.
710 A key event is propagated up the parent widget chain until a
711 widget accepts it with accept() or an event filter consumes it.
712 Key events for multimedia keys are ignored by default. You should
713 call accept() if your widget handles those events.
715 The QWidget::setEnable() function can be used to enable or disable
716 mouse and keyboard events for a widget.
718 The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(),
719 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent()
722 \sa QFocusEvent, QWidget::grabKeyboard()
726 Constructs a key event object.
728 The \a type parameter must be QEvent::KeyPress, QEvent::KeyRelease,
729 or QEvent::ShortcutOverride.
731 Int \a key is the code for the Qt::Key that the event loop should listen
732 for. If \a key is 0, the event is not a result of a known key; for
733 example, it may be the result of a compose sequence or keyboard macro.
734 The \a modifiers holds the keyboard modifiers, and the given \a text
735 is the Unicode text that the key generated. If \a autorep is true,
736 isAutoRepeat() will be true. \a count is the number of keys involved
739 QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text,
740 bool autorep, ushort count)
741 : QInputEvent(type, modifiers), txt(text), k(key), c(count), autor(autorep)
748 QKeyEvent::~QKeyEvent()
755 QKeyEvent *QKeyEvent::createExtendedKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers,
756 quint32 nativeScanCode, quint32 nativeVirtualKey,
757 quint32 nativeModifiers,
758 const QString& text, bool autorep, ushort count)
760 return new QKeyEventEx(type, key, modifiers, text, autorep, count,
761 nativeScanCode, nativeVirtualKey, nativeModifiers);
765 \fn bool QKeyEvent::hasExtendedInfo() const
772 Returns the native scan code of the key event. If the key event
773 does not contain this data 0 is returned.
775 Note: The native scan code may be 0, even if the key event contains
776 extended information.
778 Note: On Mac OS/X, this function is not useful, because there is no
779 way to get the scan code from Carbon or Cocoa. The function always
780 returns 1 (or 0 in the case explained above).
782 quint32 QKeyEvent::nativeScanCode() const
784 return (reinterpret_cast<const QKeyEvent*>(d) != this
785 ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nScanCode);
791 Returns the native virtual key, or key sym of the key event.
792 If the key event does not contain this data 0 is returned.
794 Note: The native virtual key may be 0, even if the key event contains extended information.
796 quint32 QKeyEvent::nativeVirtualKey() const
798 return (reinterpret_cast<const QKeyEvent*>(d) != this
799 ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nVirtualKey);
805 Returns the native modifiers of a key event.
806 If the key event does not contain this data 0 is returned.
808 Note: The native modifiers may be 0, even if the key event contains extended information.
810 quint32 QKeyEvent::nativeModifiers() const
812 return (reinterpret_cast<const QKeyEvent*>(d) != this
813 ? 0 : reinterpret_cast<const QKeyEventEx*>(this)->nModifiers);
818 Creates an extended key event object, which in addition to the normal key event data, also
819 contains the native scan code, virtual key and modifiers. This extra data is used by the
820 shortcut system, to determine which shortcuts to trigger.
822 QKeyEventEx::QKeyEventEx(Type type, int key, Qt::KeyboardModifiers modifiers,
823 const QString &text, bool autorep, ushort count,
824 quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers)
825 : QKeyEvent(type, key, modifiers, text, autorep, count),
826 nScanCode(nativeScanCode), nVirtualKey(nativeVirtualKey), nModifiers(nativeModifiers)
828 d = reinterpret_cast<QEventPrivate*>(this);
833 Creates a copy of an other extended key event.
835 QKeyEventEx::QKeyEventEx(const QKeyEventEx &other)
836 : QKeyEvent(QEvent::Type(other.t), other.k, other.modState, other.txt, other.autor, other.c),
837 nScanCode(other.nScanCode), nVirtualKey(other.nVirtualKey), nModifiers(other.nModifiers)
839 d = reinterpret_cast<QEventPrivate*>(this);
845 QKeyEventEx::~QKeyEventEx()
850 \fn int QKeyEvent::key() const
852 Returns the code of the key that was pressed or released.
854 See \l Qt::Key for the list of keyboard codes. These codes are
855 independent of the underlying window system. Note that this
856 function does not distinguish between capital and non-capital
857 letters, use the text() function (returning the Unicode text the
858 key generated) for this purpose.
860 A value of either 0 or Qt::Key_unknown means that the event is not
861 the result of a known key; for example, it may be the result of
862 a compose sequence, a keyboard macro, or due to key event
865 \sa Qt::WA_KeyCompression
869 \fn QString QKeyEvent::text() const
871 Returns the Unicode text that this key generated. The text
872 returned can be an empty string in cases
873 where modifier keys, such as Shift, Control, Alt, and Meta,
874 are being pressed or released. In such cases key() will contain
877 \sa Qt::WA_KeyCompression
881 Returns the keyboard modifier flags that existed immediately
882 after the event occurred.
884 \warning This function cannot always be trusted. The user can
885 confuse it by pressing both \key{Shift} keys simultaneously and
886 releasing one of them, for example.
888 \sa QApplication::keyboardModifiers()
890 //###### We must check with XGetModifierMapping
891 Qt::KeyboardModifiers QKeyEvent::modifiers() const
893 if (key() == Qt::Key_Shift)
894 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ShiftModifier);
895 if (key() == Qt::Key_Control)
896 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::ControlModifier);
897 if (key() == Qt::Key_Alt)
898 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::AltModifier);
899 if (key() == Qt::Key_Meta)
900 return Qt::KeyboardModifiers(QInputEvent::modifiers()^Qt::MetaModifier);
901 return QInputEvent::modifiers();
904 #ifndef QT_NO_SHORTCUT
906 \fn bool QKeyEvent::matches(QKeySequence::StandardKey key) const
909 Returns true if the key event matches the given standard \a key;
910 otherwise returns false.
912 bool QKeyEvent::matches(QKeySequence::StandardKey matchKey) const
914 uint searchkey = (modifiers() | key()) & ~(Qt::KeypadModifier); //The keypad modifier should not make a difference
915 uint platform = QApplicationPrivate::currentPlatform();
918 if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
919 uint oldSearchKey = searchkey;
920 searchkey &= ~(Qt::ControlModifier | Qt::MetaModifier);
921 if (oldSearchKey & Qt::ControlModifier)
922 searchkey |= Qt::MetaModifier;
923 if (oldSearchKey & Qt::MetaModifier)
924 searchkey |= Qt::ControlModifier;
928 uint N = QKeySequencePrivate::numberOfKeyBindings;
932 while (first <= last) {
933 int mid = (first + last) / 2;
934 QKeyBinding midVal = QKeySequencePrivate::keyBindings[mid];
936 if (searchkey > midVal.shortcut){
937 first = mid + 1; // Search in top half
939 else if (searchkey < midVal.shortcut){
940 last = mid - 1; // Search in bottom half
943 //found correct shortcut value, now we must check for platform match
944 if ((midVal.platform & platform) && (midVal.standardKey == matchKey)) {
946 } else { //We may have several equal values for different platforms, so we must search in both directions
949 for ( unsigned int i = mid + 1 ; i < N - 1 ; ++i) {
950 QKeyBinding current = QKeySequencePrivate::keyBindings[i];
951 if (current.shortcut != searchkey)
953 else if (current.platform & platform && current.standardKey == matchKey)
958 for ( int i = mid - 1 ; i >= 0 ; --i) {
959 QKeyBinding current = QKeySequencePrivate::keyBindings[i];
960 if (current.shortcut != searchkey)
962 else if (current.platform & platform && current.standardKey == matchKey)
965 return false; //we could not find it among the matching keySequences
969 return false; //we could not find matching keySequences at all
971 #endif // QT_NO_SHORTCUT
975 \fn bool QKeyEvent::isAutoRepeat() const
977 Returns true if this event comes from an auto-repeating key;
978 returns false if it comes from an initial key press.
980 Note that if the event is a multiple-key compressed event that is
981 partly due to auto-repeat, this function could return either true
982 or false indeterminately.
986 \fn int QKeyEvent::count() const
988 Returns the number of keys involved in this event. If text()
989 is not empty, this is simply the length of the string.
991 \sa Qt::WA_KeyCompression
996 \fn QKeyEvent::QKeyEvent(Type type, int key, int ascii,
997 int modifiers, const QString &text,
998 bool autorep, ushort count)
1000 Use one of the other constructors instead.
1004 \fn int QKeyEvent::ascii() const
1010 \fn Qt::ButtonState QKeyEvent::state() const
1012 Use QInputEvent::modifiers() instead.
1016 \fn Qt::ButtonState QKeyEvent::stateAfter() const
1018 Use modifiers() instead.
1024 \brief The QFocusEvent class contains event parameters for widget focus
1029 Focus events are sent to widgets when the keyboard input focus
1030 changes. Focus events occur due to mouse actions, key presses
1031 (such as \gui{Tab} or \gui{Backtab}), the window system, popup
1032 menus, keyboard shortcuts, or other application-specific reasons.
1033 The reason for a particular focus event is returned by reason()
1034 in the appropriate event handler.
1036 The event handlers QWidget::focusInEvent(),
1037 QWidget::focusOutEvent(), QGraphicsItem::focusInEvent and
1038 QGraphicsItem::focusOutEvent() receive focus events.
1040 \sa QWidget::setFocus(), QWidget::setFocusPolicy(), {Keyboard Focus}
1044 Constructs a focus event object.
1046 The \a type parameter must be either QEvent::FocusIn or
1047 QEvent::FocusOut. The \a reason describes the cause of the change
1050 QFocusEvent::QFocusEvent(Type type, Qt::FocusReason reason)
1051 : QEvent(type), m_reason(reason)
1057 QFocusEvent::~QFocusEvent()
1065 Qt::FocusReason QFocusEvent::reason()
1071 Returns the reason for this focus event.
1073 Qt::FocusReason QFocusEvent::reason() const
1079 \fn bool QFocusEvent::gotFocus() const
1081 Returns true if type() is QEvent::FocusIn; otherwise returns
1086 \fn bool QFocusEvent::lostFocus() const
1088 Returns true if type() is QEvent::FocusOut; otherwise returns
1094 \enum QFocusEvent::Reason
1097 Use Qt::FocusReason instead.
1099 \value Mouse Same as Qt::MouseFocusReason.
1100 \value Tab Same as Qt::TabFocusReason.
1101 \value Backtab Same as Qt::BacktabFocusReason.
1102 \value MenuBar Same as Qt::MenuBarFocusReason.
1103 \value ActiveWindow Same as Qt::ActiveWindowFocusReason
1104 \value Other Same as Qt::OtherFocusReason
1105 \value Popup Same as Qt::PopupFocusReason
1106 \value Shortcut Same as Qt::ShortcutFocusReason
1112 \brief The QPaintEvent class contains event parameters for paint events.
1116 Paint events are sent to widgets that need to update themselves,
1117 for instance when part of a widget is exposed because a covering
1120 The event contains a region() that needs to be updated, and a
1121 rect() that is the bounding rectangle of that region. Both are
1122 provided because many widgets can't make much use of region(),
1123 and rect() can be much faster than region().boundingRect().
1125 \section1 Automatic Clipping
1127 Painting is clipped to region() during the processing of a paint
1128 event. This clipping is performed by Qt's paint system and is
1129 independent of any clipping that may be applied to a QPainter used to
1130 draw on the paint device.
1132 As a result, the value returned by QPainter::clipRegion() on
1133 a newly-constructed QPainter will not reflect the clip region that is
1134 used by the paint system.
1136 \sa QPainter, QWidget::update(), QWidget::repaint(),
1137 QWidget::paintEvent()
1141 \fn bool QPaintEvent::erased() const
1144 Returns true if the paint event region (or rectangle) has been
1145 erased with the widget's background; otherwise returns false.
1147 Qt 4 \e always erases regions that require painting. The exception
1148 to this rule is if the widget sets the Qt::WA_OpaquePaintEvent or
1149 Qt::WA_NoSystemBackground attributes. If either one of those
1150 attributes is set \e and the window system does not make use of
1151 subwidget alpha composition (currently X11 and Windows, but this
1152 may change), then the region is not erased.
1156 \fn void QPaintEvent::setErased(bool b) { m_erased = b; }
1161 Constructs a paint event object with the region that needs to
1162 be updated. The region is specified by \a paintRegion.
1164 QPaintEvent::QPaintEvent(const QRegion& paintRegion)
1165 : QEvent(Paint), m_rect(paintRegion.boundingRect()), m_region(paintRegion), m_erased(false)
1169 Constructs a paint event object with the rectangle that needs
1170 to be updated. The region is specified by \a paintRect.
1172 QPaintEvent::QPaintEvent(const QRect &paintRect)
1173 : QEvent(Paint), m_rect(paintRect),m_region(paintRect), m_erased(false)
1179 Constructs a paint event object with both a \a paintRegion and a
1180 \a paintRect, both of which represent the area of the widget that
1181 needs to be updated.
1184 QPaintEvent::QPaintEvent(const QRegion &paintRegion, const QRect &paintRect)
1185 : QEvent(Paint), m_rect(paintRect), m_region(paintRegion), m_erased(false)
1192 QPaintEvent::~QPaintEvent()
1197 \fn const QRect &QPaintEvent::rect() const
1199 Returns the rectangle that needs to be updated.
1201 \sa region() QPainter::setClipRect()
1205 \fn const QRegion &QPaintEvent::region() const
1207 Returns the region that needs to be updated.
1209 \sa rect() QPainter::setClipRegion()
1213 QUpdateLaterEvent::QUpdateLaterEvent(const QRegion& paintRegion)
1214 : QEvent(UpdateLater), m_region(paintRegion)
1218 QUpdateLaterEvent::~QUpdateLaterEvent()
1224 \brief The QMoveEvent class contains event parameters for move events.
1228 Move events are sent to widgets that have been moved to a new
1229 position relative to their parent.
1231 The event handler QWidget::moveEvent() receives move events.
1233 \sa QWidget::move(), QWidget::setGeometry()
1237 Constructs a move event with the new and old widget positions,
1238 \a pos and \a oldPos respectively.
1240 QMoveEvent::QMoveEvent(const QPoint &pos, const QPoint &oldPos)
1241 : QEvent(Move), p(pos), oldp(oldPos)
1247 QMoveEvent::~QMoveEvent()
1252 \fn const QPoint &QMoveEvent::pos() const
1254 Returns the new position of the widget. This excludes the window
1255 frame for top level widgets.
1259 \fn const QPoint &QMoveEvent::oldPos() const
1261 Returns the old position of the widget.
1267 \brief The QResizeEvent class contains event parameters for resize events.
1271 Resize events are sent to widgets that have been resized.
1273 The event handler QWidget::resizeEvent() receives resize events.
1275 \sa QWidget::resize() QWidget::setGeometry()
1279 Constructs a resize event with the new and old widget sizes, \a
1280 size and \a oldSize respectively.
1282 QResizeEvent::QResizeEvent(const QSize &size, const QSize &oldSize)
1283 : QEvent(Resize), s(size), olds(oldSize)
1289 QResizeEvent::~QResizeEvent()
1294 \fn const QSize &QResizeEvent::size() const
1296 Returns the new size of the widget. This is the same as
1301 \fn const QSize &QResizeEvent::oldSize() const
1303 Returns the old size of the widget.
1309 \brief The QCloseEvent class contains parameters that describe a close event.
1313 Close events are sent to widgets that the user wants to close,
1314 usually by choosing "Close" from the window menu, or by clicking
1315 the \gui{X} title bar button. They are also sent when you call
1316 QWidget::close() to close a widget programmatically.
1318 Close events contain a flag that indicates whether the receiver
1319 wants the widget to be closed or not. When a widget accepts the
1320 close event, it is hidden (and destroyed if it was created with
1321 the Qt::WA_DeleteOnClose flag). If it refuses to accept the close
1322 event nothing happens. (Under X11 it is possible that the window
1323 manager will forcibly close the window; but at the time of writing
1324 we are not aware of any window manager that does this.)
1326 The event handler QWidget::closeEvent() receives close events. The
1327 default implementation of this event handler accepts the close
1328 event. If you do not want your widget to be hidden, or want some
1329 special handing, you should reimplement the event handler and
1332 The \l{mainwindows/application#close event handler}{closeEvent() in the
1333 Application example} shows a close event handler that
1334 asks whether to save a document before closing.
1336 If you want the widget to be deleted when it is closed, create it
1337 with the Qt::WA_DeleteOnClose flag. This is very useful for
1338 independent top-level windows in a multi-window application.
1340 \l{QObject}s emits the \l{QObject::destroyed()}{destroyed()}
1341 signal when they are deleted.
1343 If the last top-level window is closed, the
1344 QApplication::lastWindowClosed() signal is emitted.
1346 The isAccepted() function returns true if the event's receiver has
1347 agreed to close the widget; call accept() to agree to close the
1348 widget and call ignore() if the receiver of this event does not
1349 want the widget to be closed.
1351 \sa QWidget::close(), QWidget::hide(), QObject::destroyed(),
1352 QCoreApplication::exec(), QCoreApplication::quit(),
1353 QApplication::lastWindowClosed()
1357 Constructs a close event object.
1361 QCloseEvent::QCloseEvent()
1367 QCloseEvent::~QCloseEvent()
1372 \class QIconDragEvent
1373 \brief The QIconDragEvent class indicates that a main icon drag has begun.
1377 Icon drag events are sent to widgets when the main icon of a window
1378 has been dragged away. On Mac OS X, this happens when the proxy
1379 icon of a window is dragged off the title bar.
1381 It is normal to begin using drag and drop in response to this
1384 \sa {Drag and Drop}, QMimeData, QDrag
1388 Constructs an icon drag event object with the accept flag set to
1393 QIconDragEvent::QIconDragEvent()
1398 QIconDragEvent::~QIconDragEvent()
1403 \class QContextMenuEvent
1404 \brief The QContextMenuEvent class contains parameters that describe a context menu event.
1408 Context menu events are sent to widgets when a user performs
1409 an action associated with opening a context menu.
1410 The actions required to open context menus vary between platforms;
1411 for example, on Windows, pressing the menu button or clicking the
1412 right mouse button will cause this event to be sent.
1414 When this event occurs it is customary to show a QMenu with a
1415 context menu, if this is relevant to the context.
1417 Context menu events contain a special accept flag that indicates
1418 whether the receiver accepted the event. If the event handler does
1419 not accept the event then, if possible, whatever triggered the event will be
1420 handled as a regular input event.
1423 #ifndef QT_NO_CONTEXTMENU
1425 Constructs a context menu event object with the accept parameter
1428 The \a reason parameter must be QContextMenuEvent::Mouse or
1429 QContextMenuEvent::Keyboard.
1431 The \a pos parameter specifies the mouse position relative to the
1432 receiving widget. \a globalPos is the mouse position in absolute
1435 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos)
1436 : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
1440 Constructs a context menu event object with the accept parameter
1443 The \a reason parameter must be QContextMenuEvent::Mouse or
1444 QContextMenuEvent::Keyboard.
1446 The \a pos parameter specifies the mouse position relative to the
1447 receiving widget. \a globalPos is the mouse position in absolute
1448 coordinates. The \a modifiers holds the keyboard modifiers.
1450 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
1451 Qt::KeyboardModifiers modifiers)
1452 : QInputEvent(ContextMenu, modifiers), p(pos), gp(globalPos), reas(reason)
1457 Constructs a context menu event with the given \a reason for the
1458 position specified by \a pos in widget coordinates and \a globalPos
1459 in global screen coordinates. \a dummy is ignored.
1461 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, const QPoint &globalPos,
1463 : QInputEvent(ContextMenu), p(pos), gp(globalPos), reas(reason)
1468 QContextMenuEvent::~QContextMenuEvent()
1472 Constructs a context menu event object with the accept parameter
1475 The \a reason parameter must be QContextMenuEvent::Mouse or
1476 QContextMenuEvent::Keyboard.
1478 The \a pos parameter specifies the mouse position relative to the
1481 The globalPos() is initialized to QCursor::pos(), which may not be
1482 appropriate. Use the other constructor to specify the global
1483 position explicitly.
1485 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos)
1486 : QInputEvent(ContextMenu), p(pos), reas(reason)
1488 gp = QCursor::pos();
1493 Constructs a context menu event with the given \a reason for the
1494 position specified by \a pos in widget coordinates. \a dummy is
1497 QContextMenuEvent::QContextMenuEvent(Reason reason, const QPoint &pos, int /* dummy */)
1498 : QInputEvent(ContextMenu), p(pos), reas(reason)
1500 gp = QCursor::pos();
1503 Qt::ButtonState QContextMenuEvent::state() const
1505 return Qt::ButtonState(int(QApplication::keyboardModifiers())|QApplication::mouseButtons());
1510 \fn const QPoint &QContextMenuEvent::pos() const
1512 Returns the position of the mouse pointer relative to the widget
1513 that received the event.
1515 \sa x(), y(), globalPos()
1519 \fn int QContextMenuEvent::x() const
1521 Returns the x position of the mouse pointer, relative to the
1522 widget that received the event.
1528 \fn int QContextMenuEvent::y() const
1530 Returns the y position of the mouse pointer, relative to the
1531 widget that received the event.
1537 \fn const QPoint &QContextMenuEvent::globalPos() const
1539 Returns the global position of the mouse pointer at the time of
1546 \fn int QContextMenuEvent::globalX() const
1548 Returns the global x position of the mouse pointer at the time of
1551 \sa globalY(), globalPos()
1555 \fn int QContextMenuEvent::globalY() const
1557 Returns the global y position of the mouse pointer at the time of
1560 \sa globalX(), globalPos()
1562 #endif // QT_NO_CONTEXTMENU
1565 \fn Qt::ButtonState QContextMenuEvent::state() const
1567 Returns the button state (a combination of mouse buttons
1568 and keyboard modifiers) immediately before the event was
1571 The returned value is a selection of the following values,
1572 combined with the OR operator:
1573 Qt::LeftButton, Qt::RightButton, Qt::MidButton,
1574 Qt::ShiftButton, Qt::ControlButton, and Qt::AltButton.
1578 \enum QContextMenuEvent::Reason
1580 This enum describes the reason why the event was sent.
1582 \value Mouse The mouse caused the event to be sent. Normally this
1583 means the right mouse button was clicked, but this is platform
1586 \value Keyboard The keyboard caused this event to be sent. On
1587 Windows, this means the menu button was pressed.
1589 \value Other The event was sent by some other means (i.e. not by
1590 the mouse or keyboard).
1595 \fn QContextMenuEvent::Reason QContextMenuEvent::reason() const
1597 Returns the reason for this context event.
1602 \class QInputMethodEvent
1603 \brief The QInputMethodEvent class provides parameters for input method events.
1607 Input method events are sent to widgets when an input method is
1608 used to enter text into a widget. Input methods are widely used
1609 to enter text for languages with non-Latin alphabets.
1611 Note that when creating custom text editing widgets, the
1612 Qt::WA_InputMethodEnabled window attribute must be set explicitly
1613 (using the QWidget::setAttribute() function) in order to receive
1614 input method events.
1616 The events are of interest to authors of keyboard entry widgets
1617 who want to be able to correctly handle languages with complex
1618 character input. Text input in such languages is usually a three
1622 \o \bold{Starting to Compose}
1624 When the user presses the first key on a keyboard, an input
1625 context is created. This input context will contain a string
1626 of the typed characters.
1630 With every new key pressed, the input method will try to create a
1631 matching string for the text typed so far called preedit
1632 string. While the input context is active, the user can only move
1633 the cursor inside the string belonging to this input context.
1635 \o \bold{Completing}
1637 At some point, the user will activate a user interface component
1638 (perhaps using a particular key) where they can choose from a
1639 number of strings matching the text they have typed so far. The
1640 user can either confirm their choice cancel the input; in either
1641 case the input context will be closed.
1644 QInputMethodEvent models these three stages, and transfers the
1645 information needed to correctly render the intermediate result. A
1646 QInputMethodEvent has two main parameters: preeditString() and
1647 commitString(). The preeditString() parameter gives the currently
1648 active preedit string. The commitString() parameter gives a text
1649 that should get added to (or replace parts of) the text of the
1650 editor widget. It usually is a result of the input operations and
1651 has to be inserted to the widgets text directly before the preedit
1654 If the commitString() should replace parts of the of the text in
1655 the editor, replacementLength() will contain the number of
1656 characters to be replaced. replacementStart() contains the position
1657 at which characters are to be replaced relative from the start of
1660 A number of attributes control the visual appearance of the
1661 preedit string (the visual appearance of text outside the preedit
1662 string is controlled by the widget only). The AttributeType enum
1663 describes the different attributes that can be set.
1665 A class implementing QWidget::inputMethodEvent() or
1666 QGraphicsItem::inputMethodEvent() should at least understand and
1667 honor the \l TextFormat and \l Cursor attributes.
1669 Since input methods need to be able to query certain properties
1670 from the widget or graphics item, subclasses must also implement
1671 QWidget::inputMethodQuery() and QGraphicsItem::inputMethodQuery(),
1674 When receiving an input method event, the text widget has to performs the
1678 \o If the widget has selected text, the selected text should get
1681 \o Remove the text starting at replacementStart() with length
1682 replacementLength() and replace it by the commitString(). If
1683 replacementLength() is 0, replacementStart() gives the insertion
1684 position for the commitString().
1686 When doing replacement the area of the preedit
1687 string is ignored, thus a replacement starting at -1 with a length
1688 of 2 will remove the last character before the preedit string and
1689 the first character afterwards, and insert the commit string
1690 directly before the preedit string.
1692 If the widget implements undo/redo, this operation gets added to
1695 \o If there is no current preedit string, insert the
1696 preeditString() at the current cursor position; otherwise replace
1697 the previous preeditString with the one received from this event.
1699 If the widget implements undo/redo, the preeditString() should not
1700 influence the undo/redo stack in any way.
1702 The widget should examine the list of attributes to apply to the
1703 preedit string. It has to understand at least the TextFormat and
1704 Cursor attributes and render them as specified.
1711 \enum QInputMethodEvent::AttributeType
1714 A QTextCharFormat for the part of the preedit string specified by
1715 start and length. value contains a QVariant of type QTextFormat
1716 specifying rendering of this part of the preedit string. There
1717 should be at most one format for every part of the preedit
1718 string. If several are specified for any character in the string the
1719 behaviour is undefined. A conforming implementation has to at least
1720 honor the backgroundColor, textColor and fontUnderline properties
1723 \value Cursor If set, a cursor should be shown inside the preedit
1724 string at position start. The length variable determines whether
1725 the cursor is visible or not. If the length is 0 the cursor is
1726 invisible. If value is a QVariant of type QColor this color will
1727 be used for rendering the cursor, otherwise the color of the
1728 surrounding text will be used. There should be at most one Cursor
1729 attribute per event. If several are specified the behaviour is
1733 The variant contains a QLocale object specifying the language of a
1734 certain part of the preedit string. There should be at most one
1735 language set for every part of the preedit string. If several are
1736 specified for any character in the string the behavior is undefined.
1739 The ruby text for a part of the preedit string. There should be at
1740 most one ruby text set for every part of the preedit string. If
1741 several are specified for any character in the string the behaviour
1745 If set, the edit cursor should be moved to the specified position
1746 in the editor text contents. In contrast with \c Cursor, this
1747 attribute does not work on the preedit text, but on the surrounding
1748 text. The cursor will be moved after the commit string has been
1749 committed, and the preedit string will be located at the new edit
1751 The start position specifies the new position and the length
1752 variable can be used to set a selection starting from that point.
1753 The value is unused.
1759 \class QInputMethodEvent::Attribute
1760 \brief The QInputMethodEvent::Attribute class stores an input method attribute.
1764 \fn QInputMethodEvent::Attribute::Attribute(AttributeType type, int start, int length, QVariant value)
1766 Constructs an input method attribute. \a type specifies the type
1767 of attribute, \a start and \a length the position of the
1768 attribute, and \a value the value of the attribute.
1772 Constructs an event of type QEvent::InputMethod. The
1773 attributes(), preeditString(), commitString(), replacementStart(),
1774 and replacementLength() are initialized to default values.
1776 \sa setCommitString()
1778 QInputMethodEvent::QInputMethodEvent()
1779 : QEvent(QEvent::InputMethod), replace_from(0), replace_length(0)
1784 Construcs an event of type QEvent::InputMethod. The
1785 preedit text is set to \a preeditText, the attributes to
1788 The commitString(), replacementStart(), and replacementLength()
1789 values can be set using setCommitString().
1791 \sa preeditString(), attributes()
1793 QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Attribute> &attributes)
1794 : QEvent(QEvent::InputMethod), preedit(preeditText), attrs(attributes),
1795 replace_from(0), replace_length(0)
1800 Constructs a copy of \a other.
1802 QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other)
1803 : QEvent(QEvent::InputMethod), preedit(other.preedit), attrs(other.attrs),
1804 commit(other.commit), replace_from(other.replace_from), replace_length(other.replace_length)
1809 Sets the commit string to \a commitString.
1811 The commit string is the text that should get added to (or
1812 replace parts of) the text of the editor widget. It usually is a
1813 result of the input operations and has to be inserted to the
1814 widgets text directly before the preedit string.
1816 If the commit string should replace parts of the of the text in
1817 the editor, \a replaceLength specifies the number of
1818 characters to be replaced. \a replaceFrom specifies the position
1819 at which characters are to be replaced relative from the start of
1822 \sa commitString(), replacementStart(), replacementLength()
1824 void QInputMethodEvent::setCommitString(const QString &commitString, int replaceFrom, int replaceLength)
1826 commit = commitString;
1827 replace_from = replaceFrom;
1828 replace_length = replaceLength;
1832 \fn const QList<Attribute> &QInputMethodEvent::attributes() const
1834 Returns the list of attributes passed to the QInputMethodEvent
1835 constructor. The attributes control the visual appearance of the
1836 preedit string (the visual appearance of text outside the preedit
1837 string is controlled by the widget only).
1839 \sa preeditString(), Attribute
1843 \fn const QString &QInputMethodEvent::preeditString() const
1845 Returns the preedit text, i.e. the text before the user started
1848 \sa commitString(), attributes()
1852 \fn const QString &QInputMethodEvent::commitString() const
1854 Returns the text that should get added to (or replace parts of)
1855 the text of the editor widget. It usually is a result of the
1856 input operations and has to be inserted to the widgets text
1857 directly before the preedit string.
1859 \sa setCommitString(), preeditString(), replacementStart(), replacementLength()
1863 \fn int QInputMethodEvent::replacementStart() const
1865 Returns the position at which characters are to be replaced relative
1866 from the start of the preedit string.
1868 \sa replacementLength(), setCommitString()
1872 \fn int QInputMethodEvent::replacementLength() const
1874 Returns the number of characters to be replaced in the preedit
1877 \sa replacementStart(), setCommitString()
1880 #ifndef QT_NO_TABLETEVENT
1884 \brief The QTabletEvent class contains parameters that describe a Tablet event.
1888 Tablet Events are generated from a Wacom tablet. Most of the time you will
1889 want to deal with events from the tablet as if they were events from a
1890 mouse; for example, you would retrieve the cursor position with x(), y(),
1891 pos(), globalX(), globalY(), and globalPos(). In some situations you may
1892 wish to retrieve the extra information provided by the tablet device
1893 driver; for example, you might want to do subpixeling with higher
1894 resolution coordinates or you may want to adjust color brightness based on
1895 pressure. QTabletEvent allows you to read the pressure(), the xTilt(), and
1896 yTilt(), as well as the type of device being used with device() (see
1897 \l{TabletDevice}). It can also give you the minimum and maximum values for
1898 each device's pressure and high resolution coordinates.
1900 A tablet event contains a special accept flag that indicates whether the
1901 receiver wants the event. You should call QTabletEvent::accept() if you
1902 handle the tablet event; otherwise it will be sent to the parent widget.
1903 The exception are TabletEnterProximity and TabletLeaveProximity events,
1904 these are only sent to QApplication and don't check whether or not they are
1907 The QWidget::setEnabled() function can be used to enable or
1908 disable mouse and keyboard events for a widget.
1910 The event handler QWidget::tabletEvent() receives all three types of
1911 tablet events. Qt will first send a tabletEvent then, if it is not
1912 accepted, it will send a mouse event. This allows applications that
1913 don't utilize tablets to use a tablet like a mouse, while also
1914 enabling those who want to use both tablets and mouses differently.
1916 \section1 Notes for X11 Users
1918 Qt uses the following hard-coded names to identify tablet
1919 devices from the xorg.conf file on X11 (apart from IRIX):
1920 'stylus', 'pen', and 'eraser'. If the devices have other names,
1921 they will not be picked up Qt.
1925 \enum QTabletEvent::TabletDevice
1927 This enum defines what type of device is generating the event.
1929 \value NoDevice No device, or an unknown device.
1930 \value Puck A Puck (a device that is similar to a flat mouse with
1931 a transparent circle with cross-hairs).
1932 \value Stylus A Stylus.
1933 \value Airbrush An airbrush
1934 \value FourDMouse A 4D Mouse.
1935 \value RotationStylus A special stylus that also knows about rotation
1936 (a 6D stylus). \since 4.1
1937 \omitvalue XFreeEraser
1941 \enum QTabletEvent::PointerType
1943 This enum defines what type of point is generating the event.
1945 \value UnknownPointer An unknown device.
1946 \value Pen Tip end of a stylus-like device (the narrow end of the pen).
1947 \value Cursor Any puck-like device.
1948 \value Eraser Eraser end of a stylus-like device (the broad end of the pen).
1954 Construct a tablet event of the given \a type.
1956 The \a pos parameter indicates where the event occurred in the
1957 widget; \a globalPos is the corresponding position in absolute
1958 coordinates. The \a hiResGlobalPos contains a high resolution
1959 measurement of the position.
1961 \a pressure contains the pressure exerted on the \a device.
1963 \a pointerType describes the type of pen that is being used.
1965 \a xTilt and \a yTilt contain the device's degree of tilt from the
1966 x and y axes respectively.
1968 \a keyState specifies which keyboard modifiers are pressed (e.g.,
1971 The \a uniqueID parameter contains the unique ID for the current device.
1973 The \a z parameter contains the coordinate of the device on the tablet, this
1974 is usually given by a wheel on 4D mouse. If the device does not support a
1975 Z-axis, pass zero here.
1977 The \a tangentialPressure parameter contins the tangential pressure of an air
1978 brush. If the device does not support tangential pressure, pass 0 here.
1980 \a rotation contains the device's rotation in degrees. 4D mice support
1981 rotation. If the device does not support rotation, pass 0 here.
1983 \sa pos() globalPos() device() pressure() xTilt() yTilt() uniqueId(), rotation(), tangentialPressure(), z()
1986 QTabletEvent::QTabletEvent(Type type, const QPoint &pos, const QPoint &globalPos,
1987 const QPointF &hiResGlobalPos, int device, int pointerType,
1988 qreal pressure, int xTilt, int yTilt, qreal tangentialPressure,
1989 qreal rotation, int z, Qt::KeyboardModifiers keyState, qint64 uniqueID)
1990 : QInputEvent(type, keyState),
1993 mHiResGlobalPos(hiResGlobalPos),
1995 mPointerType(pointerType),
2000 mTangential(tangentialPressure),
2010 QTabletEvent::~QTabletEvent()
2015 \fn TabletDevices QTabletEvent::device() const
2017 Returns the type of device that generated the event.
2023 \fn PointerType QTabletEvent::pointerType() const
2025 Returns the type of point that generated the event.
2029 \fn qreal QTabletEvent::tangentialPressure() const
2031 Returns the tangential pressure for the device. This is typically given by a finger
2032 wheel on an airbrush tool. The range is from -1.0 to 1.0. 0.0 indicates a
2033 neutral position. Current airbrushes can only move in the positive
2034 direction from the neutrual position. If the device does not support
2035 tangential pressure, this value is always 0.0.
2041 \fn qreal QTabletEvent::rotation() const
2043 Returns the rotation of the current device in degress. This is usually
2044 given by a 4D Mouse. If the device doesn't support rotation this value is
2050 \fn qreal QTabletEvent::pressure() const
2052 Returns the pressure for the device. 0.0 indicates that the stylus is not
2053 on the tablet, 1.0 indicates the maximum amount of pressure for the stylus.
2055 \sa tangentialPressure()
2059 \fn int QTabletEvent::xTilt() const
2061 Returns the angle between the device (a pen, for example) and the
2062 perpendicular in the direction of the x axis.
2063 Positive values are towards the tablet's physical right. The angle
2064 is in the range -60 to +60 degrees.
2066 \img qtabletevent-tilt.png
2072 \fn int QTabletEvent::yTilt() const
2074 Returns the angle between the device (a pen, for example) and the
2075 perpendicular in the direction of the y axis.
2076 Positive values are towards the bottom of the tablet. The angle is
2077 within the range -60 to +60 degrees.
2083 \fn const QPoint &QTabletEvent::pos() const
2085 Returns the position of the device, relative to the widget that
2088 If you move widgets around in response to mouse events, use
2089 globalPos() instead of this function.
2091 \sa x() y() globalPos()
2095 \fn int QTabletEvent::x() const
2097 Returns the x position of the device, relative to the widget that
2104 \fn int QTabletEvent::y() const
2106 Returns the y position of the device, relative to the widget that
2113 \fn int QTabletEvent::z() const
2115 Returns the z position of the device. Typically this is represented by a
2116 wheel on a 4D Mouse. If the device does not support a Z-axis, this value is
2117 always zero. This is \bold not the same as pressure.
2123 \fn const QPoint &QTabletEvent::globalPos() const
2125 Returns the global position of the device \e{at the time of the
2126 event}. This is important on asynchronous windows systems like X11;
2127 whenever you move your widgets around in response to mouse events,
2128 globalPos() can differ significantly from the current position
2131 \sa globalX() globalY() hiResGlobalPos()
2135 \fn int QTabletEvent::globalX() const
2137 Returns the global x position of the mouse pointer at the time of
2140 \sa globalY() globalPos() hiResGlobalX()
2144 \fn int QTabletEvent::globalY() const
2146 Returns the global y position of the tablet device at the time of
2149 \sa globalX() globalPos() hiResGlobalY()
2153 \fn qint64 QTabletEvent::uniqueId() const
2155 Returns a unique ID for the current device, making it possible
2156 to differentiate between multiple devices being used at the same
2159 Support of this feature is dependent on the tablet.
2161 Values for the same device may vary from OS to OS.
2163 Later versions of the Wacom driver for Linux will now report
2164 the ID information. If you have a tablet that supports unique ID
2165 and are not getting the information on Linux, consider upgrading
2168 As of Qt 4.2, the unique ID is the same regardless of the orientation
2169 of the pen. Earlier versions would report a different value when using
2170 the eraser-end versus the pen-end of the stylus on some OS's.
2176 \fn const QPointF &QTabletEvent::hiResGlobalPos() const
2178 The high precision coordinates delivered from the tablet expressed.
2179 Sub pixeling information is in the fractional part of the QPointF.
2181 \sa globalPos() hiResGlobalX() hiResGlobalY()
2185 \fn qreal &QTabletEvent::hiResGlobalX() const
2187 The high precision x position of the tablet device.
2191 \fn qreal &QTabletEvent::hiResGlobalY() const
2193 The high precision y position of the tablet device.
2196 #endif // QT_NO_TABLETEVENT
2198 #ifndef QT_NO_DRAGANDDROP
2200 Creates a QDragMoveEvent of the required \a type indicating
2201 that the mouse is at position \a pos given within a widget.
2203 The mouse and keyboard states are specified by \a buttons and
2204 \a modifiers, and the \a actions describe the types of drag
2205 and drop operation that are possible.
2206 The drag data is passed as MIME-encoded information in \a data.
2208 \warning Do not attempt to create a QDragMoveEvent yourself.
2209 These objects rely on Qt's internal state.
2211 QDragMoveEvent::QDragMoveEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2212 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2213 : QDropEvent(pos, actions, data, buttons, modifiers, type)
2214 , rect(pos, QSize(1, 1))
2220 QDragMoveEvent::~QDragMoveEvent()
2225 \fn void QDragMoveEvent::accept(bool y)
2227 Calls setAccepted(\a y) instead.
2231 \fn void QDragMoveEvent::accept(const QRect &rectangle)
2233 The same as accept(), but also notifies that future moves will
2234 also be acceptable if they remain within the \a rectangle
2235 given on the widget. This can improve performance, but may
2236 also be ignored by the underlying system.
2238 If the rectangle is empty, drag move events will be sent
2239 continuously. This is useful if the source is scrolling in a
2244 \fn void QDragMoveEvent::accept()
2248 Calls QDropEvent::accept().
2252 \fn void QDragMoveEvent::ignore()
2256 Calls QDropEvent::ignore().
2260 \fn void QDragMoveEvent::ignore(const QRect &rectangle)
2262 The opposite of the accept(const QRect&) function.
2263 Moves within the \a rectangle are not acceptable, and will be
2268 \fn QRect QDragMoveEvent::answerRect() const
2270 Returns the rectangle in the widget where the drop will occur if accepted.
2271 You can use this information to restrict drops to certain places on the
2279 \ingroup draganddrop
2281 \brief The QDropEvent class provides an event which is sent when a
2282 drag and drop action is completed.
2284 When a widget \l{QWidget::setAcceptDrops()}{accepts drop events}, it will
2285 receive this event if it has accepted the most recent QDragEnterEvent or
2286 QDragMoveEvent sent to it.
2288 The drop event contains a proposed action, available from proposedAction(), for
2289 the widget to either accept or ignore. If the action can be handled by the
2290 widget, you should call the acceptProposedAction() function. Since the
2291 proposed action can be a combination of \l Qt::DropAction values, it may be
2292 useful to either select one of these values as a default action or ask
2293 the user to select their preferred action.
2295 If the proposed drop action is not suitable, perhaps because your custom
2296 widget does not support that action, you can replace it with any of the
2297 \l{possibleActions()}{possible drop actions} by calling setDropAction()
2298 with your preferred action. If you set a value that is not present in the
2299 bitwise OR combination of values returned by possibleActions(), the default
2300 copy action will be used. Once a replacement drop action has been set, call
2301 accept() instead of acceptProposedAction() to complete the drop operation.
2303 The mimeData() function provides the data dropped on the widget in a QMimeData
2304 object. This contains information about the MIME type of the data in addition to
2307 \sa QMimeData, QDrag, {Drag and Drop}
2311 \fn const QMimeData *QDropEvent::mimeData() const
2313 Returns the data that was dropped on the widget and its associated MIME
2318 Constructs a drop event of a certain \a type corresponding to a
2319 drop at the point specified by \a pos in the destination widget's
2322 The \a actions indicate which types of drag and drop operation can
2323 be performed, and the drag data is stored as MIME-encoded data in \a data.
2325 The states of the mouse buttons and keyboard modifiers at the time of
2326 the drop are specified by \a buttons and \a modifiers.
2327 */ // ### pos is in which coordinate system?
2328 QDropEvent::QDropEvent(const QPoint& pos, Qt::DropActions actions, const QMimeData *data,
2329 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type)
2330 : QEvent(type), p(pos), mouseState(buttons),
2331 modState(modifiers), act(actions),
2334 default_action = QDragManager::self()->defaultAction(act, modifiers);
2335 drop_action = default_action;
2340 QDropEvent::~QDropEvent()
2346 Returns a byte array containing the drag's data, in \a format.
2348 data() normally needs to get the data from the drag source, which
2349 is potentially very slow, so it's advisable to call this function
2350 only if you're sure that you will need the data in that
2351 particular \a format.
2353 The resulting data will have a size of 0 if the format was not
2356 \sa format() QByteArray::size()
2359 QByteArray QDropEvent::encodedData(const char *format) const
2361 return mdata->data(QLatin1String(format));
2366 Returns a string describing one of the available data types for
2367 this drag. Common examples are "text/plain" and "image/gif".
2368 If \a n is less than zero or greater than the number of available
2369 data types, format() returns 0.
2371 This function is provided mainly for debugging. Most drop targets
2372 will use provides().
2374 \sa data() provides()
2377 const char* QDropEvent::format(int n) const
2379 if (fmts.isEmpty()) {
2380 QStringList formats = mdata->formats();
2381 for (int i = 0; i < formats.size(); ++i)
2382 fmts.append(formats.at(i).toLatin1());
2384 if (n < 0 || n >= fmts.size())
2386 return fmts.at(n).constData();
2391 Returns true if this event provides format \a mimeType; otherwise
2397 bool QDropEvent::provides(const char *mimeType) const
2399 return mdata->formats().contains(QLatin1String(mimeType));
2403 If the source of the drag operation is a widget in this
2404 application, this function returns that source; otherwise it
2405 returns 0. The source of the operation is the first parameter to
2406 the QDrag object used instantiate the drag.
2408 This is useful if your widget needs special behavior when dragging
2413 QWidget* QDropEvent::source() const
2415 QDragManager *manager = QDragManager::self();
2416 return manager ? manager->source() : 0;
2420 void QDropEvent::setDropAction(Qt::DropAction action)
2422 if (!(action & act) && action != Qt::IgnoreAction)
2423 action = default_action;
2424 drop_action = action;
2428 \fn const QPoint& QDropEvent::pos() const
2430 Returns the position where the drop was made.
2434 \fn Qt::MouseButtons QDropEvent::mouseButtons() const
2436 Returns the mouse buttons that are pressed..
2440 \fn Qt::KeyboardModifiers QDropEvent::keyboardModifiers() const
2442 Returns the modifier keys that are pressed.
2446 \fn void QDropEvent::accept()
2451 \fn void QDropEvent::accept(bool accept)
2453 Call setAccepted(\a accept) instead.
2457 \fn void QDropEvent::acceptAction(bool accept = true)
2459 Call this to indicate that the action described by action() is
2460 accepted (i.e. if \a accept is true, which is the default), not merely
2461 the default copy action. If you call acceptAction(true), there is
2462 no need to also call accept(true).
2466 \enum QDropEvent::Action
2469 When a drag and drop action is completed, the target is expected
2470 to perform an action on the data provided by the source. This
2471 will be one of the following:
2473 \value Copy The default action. The source simply uses the data
2474 provided in the operation.
2475 \value Link The source should somehow create a link to the
2476 location specified by the data.
2477 \value Move The source should somehow move the object from the
2478 location specified by the data to a new location.
2479 \value Private The target has special knowledge of the MIME type,
2480 which the source should respond to in a similar way to
2482 \value UserAction The source and target can co-operate using
2483 special actions. This feature is not currently
2486 The Link and Move actions only makes sense if the data is a
2487 reference, for example, text/uri-list file lists (see QUriDrag).
2491 \fn void QDropEvent::setDropAction(Qt::DropAction action)
2493 Sets the \a action to be performed on the data by the target.
2494 Use this to override the \l{proposedAction()}{proposed action}
2495 with one of the \l{possibleActions()}{possible actions}.
2497 If you set a drop action that is not one of the possible actions, the
2498 drag and drop operation will default to a copy operation.
2500 Once you have supplied a replacement drop action, call accept()
2501 instead of acceptProposedAction().
2507 \fn Qt::DropAction QDropEvent::dropAction() const
2509 Returns the action to be performed on the data by the target. This may be
2510 different from the action supplied in proposedAction() if you have called
2511 setDropAction() to explicitly choose a drop action.
2517 \fn Qt::DropActions QDropEvent::possibleActions() const
2519 Returns an OR-combination of possible drop actions.
2525 \fn Qt::DropAction QDropEvent::proposedAction() const
2527 Returns the proposed drop action.
2533 \fn void QDropEvent::acceptProposedAction()
2535 Sets the drop action to be the proposed action.
2537 \sa setDropAction(), proposedAction(), {QEvent::accept()}{accept()}
2542 Use dropAction() instead.
2544 The table below shows the correspondance between the return type
2545 of action() and the return type of dropAction().
2548 \header \i Old enum value \i New enum value
2549 \row \i QDropEvent::Copy \i Qt::CopyAction
2550 \row \i QDropEvent::Move \i Qt::MoveAction
2551 \row \i QDropEvent::Link \i Qt::LinkAction
2552 \row \i other \i Qt::CopyAction
2556 QT3_SUPPORT QDropEvent::Action QDropEvent::action() const
2558 switch(drop_action) {
2559 case Qt::CopyAction:
2561 case Qt::MoveAction:
2563 case Qt::LinkAction:
2572 \fn void QDropEvent::setPoint(const QPoint &point)
2575 Sets the drop to happen at the given \a point. You do not normally
2576 need to use this as it will be set internally before your widget
2577 receives the drop event.
2578 */ // ### here too - what coordinate system?
2582 \class QDragEnterEvent
2583 \brief The QDragEnterEvent class provides an event which is sent
2584 to a widget when a drag and drop action enters it.
2587 \ingroup draganddrop
2589 A widget must accept this event in order to receive the \l
2590 {QDragMoveEvent}{drag move events} that are sent while the drag
2591 and drop action is in progress. The drag enter event is always
2592 immediately followed by a drag move event.
2594 QDragEnterEvent inherits most of its functionality from
2595 QDragMoveEvent, which in turn inherits most of its functionality
2598 \sa QDragLeaveEvent, QDragMoveEvent, QDropEvent
2602 Constructs a QDragEnterEvent that represents a drag entering a
2603 widget at the given \a point with mouse and keyboard states specified by
2604 \a buttons and \a modifiers.
2606 The drag data is passed as MIME-encoded information in \a data, and the
2607 specified \a actions describe the possible types of drag and drop
2608 operation that can be performed.
2610 \warning Do not create a QDragEnterEvent yourself since these
2611 objects rely on Qt's internal state.
2613 QDragEnterEvent::QDragEnterEvent(const QPoint& point, Qt::DropActions actions, const QMimeData *data,
2614 Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
2615 : QDragMoveEvent(point, actions, data, buttons, modifiers, DragEnter)
2620 QDragEnterEvent::~QDragEnterEvent()
2625 Constructs a drag response event containing the \a accepted value,
2626 indicating whether the drag and drop operation was accepted by the
2629 QDragResponseEvent::QDragResponseEvent(bool accepted)
2630 : QEvent(DragResponse), a(accepted)
2635 QDragResponseEvent::~QDragResponseEvent()
2640 \class QDragMoveEvent
2641 \brief The QDragMoveEvent class provides an event which is sent while a drag and drop action is in progress.
2644 \ingroup draganddrop
2646 A widget will receive drag move events repeatedly while the drag
2647 is within its boundaries, if it accepts
2648 \l{QWidget::setAcceptDrops()}{drop events} and \l
2649 {QWidget::dragEnterEvent()}{enter events}. The widget should
2650 examine the event to see what kind of data it
2651 \l{QDragMoveEvent::provides()}{provides}, and call the accept()
2652 function to accept the drop if appropriate.
2654 The rectangle supplied by the answerRect() function can be used to restrict
2655 drops to certain parts of the widget. For example, we can check whether the
2656 rectangle intersects with the geometry of a certain child widget and only
2657 call \l{QDropEvent::acceptProposedAction()}{acceptProposedAction()} if that
2660 Note that this class inherits most of its functionality from
2663 \sa QDragEnterEvent, QDragLeaveEvent, QDropEvent
2667 \class QDragLeaveEvent
2668 \brief The QDragLeaveEvent class provides an event that is sent to a widget when a drag and drop action leaves it.
2671 \ingroup draganddrop
2673 This event is always preceded by a QDragEnterEvent and a series
2674 of \l{QDragMoveEvent}s. It is not sent if a QDropEvent is sent
2677 \sa QDragEnterEvent, QDragMoveEvent, QDropEvent
2681 Constructs a QDragLeaveEvent.
2683 \warning Do not create a QDragLeaveEvent yourself since these
2684 objects rely on Qt's internal state.
2686 QDragLeaveEvent::QDragLeaveEvent()
2692 QDragLeaveEvent::~QDragLeaveEvent()
2695 #endif // QT_NO_DRAGANDDROP
2699 \brief The QHelpEvent class provides an event that is used to request helpful information
2700 about a particular point in a widget.
2705 This event can be intercepted in applications to provide tooltips
2706 or "What's This?" help for custom widgets. The type() can be
2707 either QEvent::ToolTip or QEvent::WhatsThis.
2709 \sa QToolTip, QWhatsThis, QStatusTipEvent, QWhatsThisClickedEvent
2713 Constructs a help event with the given \a type corresponding to the
2714 widget-relative position specified by \a pos and the global position
2715 specified by \a globalPos.
2717 \a type must be either QEvent::ToolTip or QEvent::WhatsThis.
2719 \sa pos(), globalPos()
2721 QHelpEvent::QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos)
2722 : QEvent(type), p(pos), gp(globalPos)
2726 \fn int QHelpEvent::x() const
2730 \sa y(), pos(), globalPos()
2734 \fn int QHelpEvent::y() const
2738 \sa x(), pos(), globalPos()
2742 \fn int QHelpEvent::globalX() const
2744 Same as globalPos().x().
2746 \sa x(), globalY(), globalPos()
2750 \fn int QHelpEvent::globalY() const
2752 Same as globalPos().y().
2754 \sa y(), globalX(), globalPos()
2758 \fn const QPoint &QHelpEvent::pos() const
2760 Returns the mouse cursor position when the event was generated,
2761 relative to the widget to which the event is dispatched.
2763 \sa globalPos(), x(), y()
2767 \fn const QPoint &QHelpEvent::globalPos() const
2769 Returns the mouse cursor position when the event was generated
2770 in global coordinates.
2772 \sa pos(), globalX(), globalY()
2777 QHelpEvent::~QHelpEvent()
2781 #ifndef QT_NO_STATUSTIP
2784 \class QStatusTipEvent
2785 \brief The QStatusTipEvent class provides an event that is used to show messages in a status bar.
2790 Status tips can be set on a widget using the
2791 QWidget::setStatusTip() function. They are shown in the status
2792 bar when the mouse cursor enters the widget. For example:
2797 \snippet doc/src/snippets/qstatustipevent/main.cpp 1
2799 \snippet doc/src/snippets/qstatustipevent/main.cpp 3
2801 \image qstatustipevent-widget.png Widget with status tip.
2804 Status tips can also be set on actions using the
2805 QAction::setStatusTip() function:
2810 \snippet doc/src/snippets/qstatustipevent/main.cpp 0
2811 \snippet doc/src/snippets/qstatustipevent/main.cpp 2
2813 \snippet doc/src/snippets/qstatustipevent/main.cpp 3
2815 \image qstatustipevent-action.png Action with status tip.
2818 Finally, status tips are supported for the item view classes
2819 through the Qt::StatusTipRole enum value.
2821 \sa QStatusBar, QHelpEvent, QWhatsThisClickedEvent
2825 Constructs a status tip event with the text specified by \a tip.
2829 QStatusTipEvent::QStatusTipEvent(const QString &tip)
2830 : QEvent(StatusTip), s(tip)
2835 QStatusTipEvent::~QStatusTipEvent()
2840 \fn QString QStatusTipEvent::tip() const
2842 Returns the message to show in the status bar.
2844 \sa QStatusBar::showMessage()
2847 #endif // QT_NO_STATUSTIP
2849 #ifndef QT_NO_WHATSTHIS
2852 \class QWhatsThisClickedEvent
2853 \brief The QWhatsThisClickedEvent class provides an event that
2854 can be used to handle hyperlinks in a "What's This?" text.
2859 \sa QWhatsThis, QHelpEvent, QStatusTipEvent
2863 Constructs an event containing a URL specified by \a href when a link
2864 is clicked in a "What's This?" message.
2868 QWhatsThisClickedEvent::QWhatsThisClickedEvent(const QString &href)
2869 : QEvent(WhatsThisClicked), s(href)
2874 QWhatsThisClickedEvent::~QWhatsThisClickedEvent()
2879 \fn QString QWhatsThisClickedEvent::href() const
2881 Returns the URL that was clicked by the user in the "What's
2885 #endif // QT_NO_WHATSTHIS
2887 #ifndef QT_NO_ACTION
2891 \brief The QActionEvent class provides an event that is generated
2892 when a QAction is added, removed, or changed.
2896 Actions can be added to widgets using QWidget::addAction(). This
2897 generates an \l ActionAdded event, which you can handle to provide
2898 custom behavior. For example, QToolBar reimplements
2899 QWidget::actionEvent() to create \l{QToolButton}s for the
2902 \sa QAction, QWidget::addAction(), QWidget::removeAction(), QWidget::actions()
2906 Constructs an action event. The \a type can be \l ActionChanged,
2907 \l ActionAdded, or \l ActionRemoved.
2909 \a action is the action that is changed, added, or removed. If \a
2910 type is ActionAdded, the action is to be inserted before the
2911 action \a before. If \a before is 0, the action is appended.
2913 QActionEvent::QActionEvent(int type, QAction *action, QAction *before)
2914 : QEvent(static_cast<QEvent::Type>(type)), act(action), bef(before)
2919 QActionEvent::~QActionEvent()
2924 \fn QAction *QActionEvent::action() const
2926 Returns the action that is changed, added, or removed.
2932 \fn QAction *QActionEvent::before() const
2934 If type() is \l ActionAdded, returns the action that should
2935 appear before action(). If this function returns 0, the action
2936 should be appended to already existing actions on the same
2939 \sa action(), QWidget::actions()
2942 #endif // QT_NO_ACTION
2946 \brief The QHideEvent class provides an event which is sent after a widget is hidden.
2950 This event is sent just before QWidget::hide() returns, and also
2951 when a top-level window has been hidden (iconified) by the user.
2953 If spontaneous() is true, the event originated outside the
2954 application. In this case, the user hid the window using the
2955 window manager controls, either by iconifying the window or by
2956 switching to another virtual desktop where the window isn't
2957 visible. The window will become hidden but not withdrawn. If the
2958 window was iconified, QWidget::isMinimized() returns true.
2964 Constructs a QHideEvent.
2966 QHideEvent::QHideEvent()
2972 QHideEvent::~QHideEvent()
2978 \brief The QShowEvent class provides an event that is sent when a widget is shown.
2982 There are two kinds of show events: show events caused by the
2983 window system (spontaneous), and internal show events. Spontaneous (QEvent::spontaneous())
2984 show events are sent just after the window system shows the
2985 window; they are also sent when a top-level window is redisplayed
2986 after being iconified. Internal show events are delivered just
2987 before the widget becomes visible.
2993 Constructs a QShowEvent.
2995 QShowEvent::QShowEvent()
3001 QShowEvent::~QShowEvent()
3006 \fn QByteArray QDropEvent::data(const char* f) const
3010 The encoded data is in \a f.
3011 Use QDropEvent::encodedData().
3015 \class QFileOpenEvent
3016 \brief The QFileOpenEvent class provides an event that will be
3017 sent when there is a request to open a file or a URL.
3021 File open events will be sent to the QApplication::instance()
3022 when the operating system requests that a file or URL should be opened.
3023 This is a high-level event that can be caused by different user actions
3024 depending on the user's desktop environment; for example, double
3025 clicking on an file icon in the Finder on Mac OS X.
3027 This event is only used to notify the application of a request.
3028 It may be safely ignored.
3030 \note This class is currently supported for Mac OS X and Symbian only.
3033 QFileOpenEventPrivate::~QFileOpenEventPrivate()
3043 Constructs a file open event for the given \a file.
3045 QFileOpenEvent::QFileOpenEvent(const QString &file)
3046 : QEvent(FileOpen), f(file)
3048 d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(QUrl::fromLocalFile(file)));
3054 Constructs a file open event for the given \a url.
3056 QFileOpenEvent::QFileOpenEvent(const QUrl &url)
3059 d = reinterpret_cast<QEventPrivate *>(new QFileOpenEventPrivate(url));
3060 f = url.toLocalFile();
3066 QFileOpenEvent::QFileOpenEvent(const RFile &fileHandle)
3070 fileHandle.FullName(fullName);
3071 f = qt_TDesC2QString(fullName);
3072 QScopedPointer<QFileOpenEventPrivate> priv(new QFileOpenEventPrivate(QUrl::fromLocalFile(f)));
3073 // Duplicate here allows the file handle to be valid after S60 app construction is complete.
3074 qt_symbian_throwIfError(priv->file.Duplicate(fileHandle));
3075 d = reinterpret_cast<QEventPrivate *>(priv.take());
3081 QFileOpenEvent::~QFileOpenEvent()
3083 delete reinterpret_cast<QFileOpenEventPrivate *>(d);
3087 \fn QString QFileOpenEvent::file() const
3089 Returns the file that is being opened.
3093 \fn QUrl QFileOpenEvent::url() const
3095 Returns the url that is being opened.
3099 QUrl QFileOpenEvent::url() const
3101 return reinterpret_cast<const QFileOpenEventPrivate *>(d)->url;
3105 \fn bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
3107 Opens a QFile on the \a file referenced by this event in the mode specified
3108 by \a flags. Returns true if successful; otherwise returns false.
3110 This is necessary as some files cannot be opened by name, but require specific
3111 information stored in this event.
3112 For example, if this QFileOpenEvent contains a request to open a Symbian data caged file,
3113 the QFile could only be opened from the Symbian RFile used in the construction of this event.
3117 bool QFileOpenEvent::openFile(QFile &file, QIODevice::OpenMode flags) const
3119 file.setFileName(f);
3121 const QFileOpenEventPrivate *priv = reinterpret_cast<const QFileOpenEventPrivate *>(d);
3122 if (priv->file.SubSessionHandle()) {
3124 // Duplicate here means that the opened QFile will continue to be valid beyond the lifetime of this QFileOpenEvent.
3125 // It also allows openFile to be used in threads other than the thread in which the QFileOpenEvent was created.
3126 if (dup.Duplicate(priv->file) == KErrNone) {
3127 QScopedPointer<RFile, QScopedPointerRCloser<RFile> > dupCloser(&dup);
3128 bool open = file.open(dup, flags, QFile::AutoCloseHandle);
3134 return file.open(flags);
3137 #ifndef QT_NO_TOOLBAR
3140 \class QToolBarChangeEvent
3141 \brief The QToolBarChangeEvent class provides an event that is
3142 sent whenever a the toolbar button is clicked on Mac OS X.
3146 The QToolBarChangeEvent is sent when the toolbar button is clicked. On Mac
3147 OS X, this is the long oblong button on the right side of the window
3148 title bar. The default implementation is to toggle the appearance (hidden or
3149 shown) of the associated toolbars for the window.
3155 Construct a QToolBarChangeEvent given the current button state in \a state.
3157 QToolBarChangeEvent::QToolBarChangeEvent(bool t)
3158 : QEvent(ToolBarChange), tog(t)
3163 QToolBarChangeEvent::~QToolBarChangeEvent()
3168 \fn bool QToolBarChangeEvent::toggle() const
3173 \fn Qt::ButtonState QToolBarChangeEvent::state() const
3175 Returns the keyboard modifier flags at the time of the event.
3177 The returned value is a selection of the following values,
3178 combined using the OR operator:
3179 Qt::ShiftButton, Qt::ControlButton, Qt::MetaButton, and Qt::AltButton.
3182 #endif // QT_NO_TOOLBAR
3184 #ifndef QT_NO_SHORTCUT
3187 Constructs a shortcut event for the given \a key press,
3188 associated with the QShortcut ID \a id.
3190 \a ambiguous specifies whether there is more than one QShortcut
3191 for the same key sequence.
3193 QShortcutEvent::QShortcutEvent(const QKeySequence &key, int id, bool ambiguous)
3194 : QEvent(Shortcut), sequence(key), ambig(ambiguous), sid(id)
3199 Destroys the event object.
3201 QShortcutEvent::~QShortcutEvent()
3205 #endif // QT_NO_SHORTCUT
3207 #ifndef QT_NO_DEBUG_STREAM
3209 QDebug operator<<(QDebug, const QTouchEvent::TouchPoint &);
3211 static inline void formatTouchPoint(QDebug d, const QTouchEvent::TouchPoint &tp)
3213 d << "TouchPoint(" << tp.id() << ' ' << tp.rect();
3214 switch (tp.state()) {
3215 case Qt::TouchPointPressed:
3218 case Qt::TouchPointReleased:
3221 case Qt::TouchPointMoved:
3224 case Qt::TouchPointStationary:
3227 case Qt::TouchPointStateMask: // Qt 4 only
3229 case Qt::TouchPointPrimary:
3236 static inline void formatTouchEvent(QDebug d, const char *name, const QTouchEvent &t)
3238 d << "QTouchEvent(" << name << " states: " << t.touchPointStates();
3239 d << ", " << t.touchPoints().size() << " points: " << t.touchPoints() << ')';
3242 static void formatUnicodeString(QDebug d, const QString &s)
3245 for (int i = 0; i < s.size(); ++i) {
3248 d << "U+" << s.at(i).unicode();
3253 static inline void formatInputMethodEvent(QDebug d, const QInputMethodEvent *e)
3255 d << "QInputMethodEvent(";
3256 if (!e->preeditString().isEmpty()) {
3258 formatUnicodeString(d, e->preeditString());
3260 if (!e->commitString().isEmpty()) {
3262 formatUnicodeString(d, e->commitString());
3264 if (e->replacementLength()) {
3265 d << ", replacementStart=" << e->replacementStart() << ", replacementLength="
3266 << e->replacementLength();
3268 if (const int attributeCount = e->attributes().size()) {
3269 d << ", attributes= {";
3270 for (int a = 0; a < attributeCount; ++a) {
3271 const QInputMethodEvent::Attribute &at = e->attributes().at(a);
3274 d << "[type= " << at.type << ", start=" << at.start << ", length=" << at.length
3275 << ", value=" << at.value << ']';
3282 static const char *eventTypeName(QEvent::Type t)
3284 static const int enumIdx = QEvent::staticMetaObject.indexOfEnumerator("Type");
3285 return t <= QEvent::User
3286 ? QEvent::staticMetaObject.enumerator(enumIdx).valueToKey(t)
3290 static const char *eventClassName(QEvent::Type t)
3293 case QEvent::ActionAdded:
3294 case QEvent::ActionRemoved:
3295 case QEvent::ActionChanged:
3296 return "QActionEvent";
3297 case QEvent::MouseButtonPress:
3298 case QEvent::MouseButtonRelease:
3299 case QEvent::MouseButtonDblClick:
3300 case QEvent::MouseMove:
3301 case QEvent::NonClientAreaMouseMove:
3302 case QEvent::NonClientAreaMouseButtonPress:
3303 case QEvent::NonClientAreaMouseButtonRelease:
3304 case QEvent::NonClientAreaMouseButtonDblClick:
3305 return "QMouseEvent";
3306 case QEvent::DragEnter:
3307 return "QDragEnterEvent";
3308 case QEvent::DragMove:
3309 return "QDragMoveEvent";
3311 return "QDropEvent";
3312 case QEvent::KeyPress:
3313 case QEvent::KeyRelease:
3314 case QEvent::ShortcutOverride:
3316 case QEvent::FocusIn:
3317 case QEvent::FocusOut:
3318 return "QFocusEvent";
3319 case QEvent::ChildAdded:
3320 case QEvent::ChildPolished:
3321 case QEvent::ChildRemoved:
3323 case QEvent::ChildInsertedRequest:
3324 case QEvent::ChildInserted:
3326 return "QChildEvent";
3328 return "QPaintEvent";
3330 return "QMoveEvent";
3331 case QEvent::Resize:
3332 return "QResizeEvent";
3334 return "QShowEvent";
3336 return "QHideEvent";
3338 return "QEnterEvent";
3340 return "QCloseEvent";
3341 case QEvent::FileOpen:
3342 return "QFileOpenEvent";
3343 #ifndef QT_NO_GESTURES
3344 case QEvent::NativeGesture:
3345 return "QNativeGestureEvent";
3346 case QEvent::Gesture:
3347 case QEvent::GestureOverride:
3348 return "QGestureEvent";
3350 case QEvent::HoverEnter:
3351 case QEvent::HoverLeave:
3352 case QEvent::HoverMove:
3353 return "QHoverEvent";
3354 case QEvent::TabletEnterProximity:
3355 case QEvent::TabletLeaveProximity:
3356 case QEvent::TabletPress:
3357 case QEvent::TabletMove:
3358 case QEvent::TabletRelease:
3359 return "QTabletEvent";
3360 case QEvent::StatusTip:
3361 return "QStatusTipEvent";
3362 case QEvent::ToolTip:
3363 return "QHelpEvent";
3364 case QEvent::WindowStateChange:
3365 return "QWindowStateChangeEvent";
3367 return "QWheelEvent";
3368 case QEvent::TouchBegin:
3369 case QEvent::TouchUpdate:
3370 case QEvent::TouchEnd:
3371 return "QTouchEvent";
3372 case QEvent::Shortcut:
3373 return "QShortcutEvent";
3374 case QEvent::InputMethod:
3375 return "QInputMethodEvent";
3376 case QEvent::GraphicsSceneMouseMove:
3377 case QEvent::GraphicsSceneMousePress:
3378 case QEvent::GraphicsSceneMouseRelease:
3379 case QEvent::GraphicsSceneMouseDoubleClick:
3380 return "QGraphicsSceneMouseEvent";
3381 case QEvent::GraphicsSceneContextMenu:
3382 case QEvent::GraphicsSceneHoverEnter:
3383 case QEvent::GraphicsSceneHoverMove:
3384 case QEvent::GraphicsSceneHoverLeave:
3385 case QEvent::GraphicsSceneHelp:
3386 case QEvent::GraphicsSceneDragEnter:
3387 case QEvent::GraphicsSceneDragMove:
3388 case QEvent::GraphicsSceneDragLeave:
3389 case QEvent::GraphicsSceneDrop:
3390 case QEvent::GraphicsSceneWheel:
3391 return "QGraphicsSceneEvent";
3393 return "QTimerEvent";
3401 // Make protected QObject::staticQtMetaObject accessible for formatting enums.
3402 class DebugHelper : public QObject {
3404 static const char *mouseButtonToString(Qt::MouseButton button)
3406 static const int enumIdx = QObject::staticQtMetaObject.indexOfEnumerator("MouseButtons");
3407 return QObject::staticQtMetaObject.enumerator(enumIdx).valueToKey(button);
3410 static QByteArray mouseButtonsToString(Qt::MouseButtons buttons)
3413 for (int i = 0; (uint)(1 << i) <= Qt::MouseButtonMask; ++i) {
3414 const Qt::MouseButton button = static_cast<Qt::MouseButton>(1 << i);
3415 if (buttons.testFlag(button)) {
3416 if (!result.isEmpty())
3418 result.append(mouseButtonToString(button));
3421 if (result.isEmpty())
3422 result.append("NoButton");
3428 # ifndef QT_NO_DRAGANDDROP
3430 static void formatDropEvent(QDebug d, const QDropEvent *e)
3432 const QEvent::Type type = e->type();
3433 d << eventClassName(type) << "(dropAction=" << e->dropAction() << ", proposedAction="
3434 << e->proposedAction() << ", possibleActions=" << e->possibleActions();
3435 if (type == QEvent::DragMove || type == QEvent::DragEnter)
3436 d << ", answerRect=" << static_cast<const QDragMoveEvent *>(e)->answerRect();
3437 d << ", formats=" << e->mimeData()->formats();
3438 if (const Qt::KeyboardModifiers mods = e->keyboardModifiers())
3439 d << ", keyboardModifiers=" << mods;
3440 d << ", " << DebugHelper::mouseButtonsToString(e->mouseButtons()).constData();
3443 # endif // !QT_NO_DRAGANDDROP
3445 # ifndef QT_NO_TABLETEVENT
3447 static void formatTabletEvent(QDebug d, const QTabletEvent *e)
3449 const QEvent::Type type = e->type();
3451 static const int deviceEnumIdx = QTabletEvent::staticMetaObject.indexOfEnumerator("TabletDevice");
3452 static const int pointerTypeEnumIdx = QTabletEvent::staticMetaObject.indexOfEnumerator("PointerType");
3453 const char* device = QTabletEvent::staticMetaObject.enumerator(deviceEnumIdx).valueToKey(e->device());
3454 const char* pointerType = QTabletEvent::staticMetaObject.enumerator(pointerTypeEnumIdx).valueToKey(e->pointerType());
3456 d << eventClassName(type) << '(' << eventTypeName(type)
3457 << ", device=" << device
3458 << ", pointerType=" << pointerType
3459 << ", uniqueId=" << e->uniqueId()
3461 << ", xTilt=" << e->xTilt()
3462 << ", yTilt=" << e->yTilt();
3463 if (type == QEvent::TabletPress || type == QEvent::TabletMove)
3464 d << ", pressure=" << e->pressure();
3465 if (e->device() == QTabletEvent::RotationStylus || e->device() == QTabletEvent::FourDMouse)
3466 d << ", rotation=" << e->rotation();
3467 if (e->device() == QTabletEvent::Airbrush)
3468 d << ", tangentialPressure=" << e->tangentialPressure();
3471 # endif // !QT_NO_TABLETEVENT
3473 QDebug operator<<(QDebug dbg, const QTouchEvent::TouchPoint &tp)
3475 formatTouchPoint(dbg, tp);
3479 QDebug operator<<(QDebug dbg, const QEvent *e) {
3480 #ifndef Q_BROKEN_DEBUG_STREAM
3483 dbg << "QEvent(this = 0x0)";
3487 // More useful event output could be added here
3488 const QEvent::Type type = e->type();
3490 case QEvent::MouseButtonPress:
3491 case QEvent::MouseMove:
3492 case QEvent::MouseButtonRelease:
3493 case QEvent::MouseButtonDblClick:
3494 case QEvent::NonClientAreaMouseButtonPress:
3495 case QEvent::NonClientAreaMouseMove:
3496 case QEvent::NonClientAreaMouseButtonRelease:
3497 case QEvent::NonClientAreaMouseButtonDblClick:
3499 const QMouseEvent *me = static_cast<const QMouseEvent*>(e);
3500 const Qt::MouseButton button = me->button();
3501 const Qt::MouseButtons buttons = me->buttons();
3502 dbg << "QMouseEvent(" << eventTypeName(type);
3503 if (type != QEvent::MouseMove && type != QEvent::NonClientAreaMouseMove)
3504 dbg << ", " << DebugHelper::mouseButtonToString(button);
3505 if (buttons && button != buttons)
3506 dbg << ", buttons=" << DebugHelper::mouseButtonsToString(buttons).constData();
3507 if (const int mods = int(me->modifiers()))
3508 dbg << ", modifiers=0x" << hex << mods << dec;
3512 # ifndef QT_NO_WHEELEVENT
3513 case QEvent::Wheel: {
3514 const QWheelEvent *we = static_cast<const QWheelEvent *>(e);
3515 dbg << "QWheelEvent(" << "delta=" << we->delta() << ", pos=" << we->pos()
3516 << ", orientation=" << we->orientation() << ')';
3519 # endif // !QT_NO_WHEELEVENT
3520 case QEvent::KeyPress:
3521 case QEvent::KeyRelease:
3522 case QEvent::ShortcutOverride:
3524 const QKeyEvent *ke = static_cast<const QKeyEvent *>(e);
3525 dbg << "QKeyEvent(" << eventTypeName(type)
3526 << ", key=0x" << hex << ke->key() << dec;
3527 if (const int mods = ke->modifiers())
3528 dbg << ", modifiers=0x" << hex << mods << dec;
3529 if (!ke->text().isEmpty())
3530 dbg << ", text=" << ke->text();
3531 if (ke->isAutoRepeat())
3532 dbg << ", autorepeat, count=" << ke->count();
3536 case QEvent::Shortcut: {
3537 const QShortcutEvent *se = static_cast<const QShortcutEvent *>(e);
3538 dbg << "QShortcutEvent(" << se->key().toString() << ", id=" << se->shortcutId();
3539 if (se->isAmbiguous())
3540 dbg << ", ambiguous";
3544 case QEvent::FocusIn:
3545 case QEvent::FocusOut:
3546 dbg << "QFocusEvent(" << eventTypeName(type) << ", "
3547 << static_cast<const QFocusEvent *>(e)->reason() << ')';
3549 case QEvent::Move: {
3550 const QMoveEvent *me = static_cast<const QMoveEvent *>(e);
3551 dbg << "QMoveEvent(" << me->pos();
3552 if (!me->spontaneous())
3553 dbg << ", non-spontaneous";
3557 case QEvent::Resize: {
3558 const QResizeEvent *re = static_cast<const QResizeEvent *>(e);
3559 dbg << "QResizeEvent(" << re->size();
3560 if (!re->spontaneous())
3561 dbg << ", non-spontaneous";
3565 # ifndef QT_NO_DRAGANDDROP
3566 case QEvent::DragEnter:
3567 case QEvent::DragMove:
3569 formatDropEvent(dbg, static_cast<const QDropEvent *>(e));
3571 # endif // !QT_NO_DRAGANDDROP
3572 case QEvent::InputMethod:
3573 formatInputMethodEvent(dbg, static_cast<const QInputMethodEvent *>(e));
3575 case QEvent::TouchBegin:
3576 case QEvent::TouchUpdate:
3577 case QEvent::TouchEnd:
3578 formatTouchEvent(dbg, eventTypeName(type), *static_cast<const QTouchEvent*>(e));
3580 case QEvent::ChildAdded:
3581 case QEvent::ChildPolished:
3582 case QEvent::ChildRemoved:
3583 dbg << "QChildEvent(" << eventTypeName(type) << ", " << (static_cast<const QChildEvent*>(e))->child() << ')';
3585 # ifndef QT_NO_GESTURES
3586 case QEvent::NativeGesture: {
3587 const QNativeGestureEvent *ne = static_cast<const QNativeGestureEvent *>(e);
3588 dbg << "QNativeGestureEvent(type=" << ne->type() << ", percentage=" << ne->percentage
3589 << "position=" << ne->position << ", angle=" << ne->angle << ')';
3592 # endif // !QT_NO_GESTURES
3593 case QEvent::ContextMenu:
3594 dbg << "QContextMenuEvent(" << static_cast<const QContextMenuEvent *>(e)->pos() << ')';
3596 # ifndef QT_NO_TABLETEVENT
3597 case QEvent::TabletEnterProximity:
3598 case QEvent::TabletLeaveProximity:
3599 case QEvent::TabletPress:
3600 case QEvent::TabletMove:
3601 case QEvent::TabletRelease:
3602 formatTabletEvent(dbg, static_cast<const QTabletEvent *>(e));
3604 # endif // !QT_NO_TABLETEVENT
3606 dbg << "QTimerEvent(id=" << static_cast<const QTimerEvent *>(e)->timerId() << ')';
3609 dbg << eventClassName(type) << '(' << eventTypeName(type) << ", "
3610 << (const void *)e << ", type = " << e->type() << ')';
3615 #else // !Q_BROKEN_DEBUG_STREAM
3616 qWarning("This compiler doesn't support streaming QEvent to QDebug");
3623 #ifndef QT_NO_CLIPBOARD
3625 \class QClipboardEvent
3629 \brief The QClipboardEvent class provides the parameters used in a clipboard event.
3631 This class is for internal use only, and exists to aid the clipboard on various
3632 platforms to get all the information it needs. Use QEvent::Clipboard instead.
3637 QClipboardEvent::QClipboardEvent(QEventPrivate *data)
3638 : QEvent(QEvent::Clipboard)
3643 QClipboardEvent::~QClipboardEvent()
3646 #endif // QT_NO_CLIPBOARD
3649 \class QShortcutEvent
3650 \brief The QShortcutEvent class provides an event which is generated when
3651 the user presses a key combination.
3655 Normally you don't need to use this class directly; QShortcut
3656 provides a higher-level interface to handle shortcut keys.
3662 \fn const QKeySequence &QShortcutEvent::key() const
3664 Returns the key sequence that triggered the event.
3669 \fn const QKeySequence &QShortcutEvent::key()
3675 \fn int QShortcutEvent::shortcutId() const
3677 Returns the ID of the QShortcut object for which this event was
3685 \fn int QShortcutEvent::shortcutId()
3692 \fn bool QShortcutEvent::isAmbiguous() const
3694 Returns true if the key sequence that triggered the event is
3697 \sa QShortcut::activatedAmbiguously()
3702 \fn bool QShortcutEvent::isAmbiguous()
3708 \class QWindowStateChangeEvent
3711 \brief The QWindowStateChangeEvent class provides the window state before a
3712 window state change.
3715 /*! \fn Qt::WindowStates QWindowStateChangeEvent::oldState() const
3717 Returns the state of the window before the change.
3722 QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s)
3723 : QEvent(WindowStateChange), ostate(s)
3729 QWindowStateChangeEvent::QWindowStateChangeEvent(Qt::WindowStates s, bool isOverride)
3730 : QEvent(WindowStateChange), ostate(s)
3733 d = (QEventPrivate*)(this);
3738 bool QWindowStateChangeEvent::isOverride() const
3745 QWindowStateChangeEvent::~QWindowStateChangeEvent()
3752 \class QMenubarUpdatedEvent
3754 Event sent by QMenuBar to tell Q3Workspace to update itself.
3760 QMenubarUpdatedEvent::QMenubarUpdatedEvent(QMenuBar * const menuBar)
3761 :QEvent(QEvent::MenubarUpdated), m_menuBar(menuBar) {}
3764 \fn QMenuBar *QMenubarUpdatedEvent::menuBar()
3769 \fn bool operator==(QKeyEvent *e, QKeySequence::StandardKey key)
3773 Returns true if \a key is currently bound to the key combination
3776 Equivalent to \c {e->matches(key)}.
3780 \fn bool operator==(QKeySequence::StandardKey key, QKeyEvent *e)
3784 Returns true if \a key is currently bound to the key combination
3787 Equivalent to \c {e->matches(key)}.
3796 \brief The QKeyEventEx class provides more extended information about a keyevent.
3798 This class is for internal use only, and exists to aid the shortcut system on
3799 various platforms to get all the information it needs.
3806 \brief The QTouchEvent class contains parameters that describe a touch event.
3811 \section1 Enabling Touch Events
3813 Touch events occur when pressing, releasing, or moving one or more touch points on a touch
3814 device (such as a touch-screen or track-pad). To receive touch events, widgets have to have the
3815 Qt::WA_AcceptTouchEvents attribute set and graphics items need to have the
3816 \l{QGraphicsItem::setAcceptTouchEvents()}{acceptTouchEvents} attribute set to true.
3818 When using QAbstractScrollArea based widgets, you should enable the Qt::WA_AcceptTouch