Qt 4.8
Public Functions | Static Public Functions | Protected Variables | List of all members
QMouseEvent Class Reference

The QMouseEvent class contains parameters that describe a mouse event. More...

#include <qevent.h>

Inheritance diagram for QMouseEvent:
QInputEvent QEvent QMouseEventEx

Public Functions

Qt::MouseButton button () const
 Returns the button that caused the event. More...
 
Qt::MouseButtons buttons () const
 Returns the button state when the event was generated. More...
 
const QPointglobalPos () const
 Returns the global position of the mouse cursor at the time of the event. More...
 
int globalX () const
 Returns the global x position of the mouse cursor at the time of the event. More...
 
int globalY () const
 Returns the global y position of the mouse cursor at the time of the event. More...
 
bool hasExtendedInfo () const
 
const QPointpos () const
 Returns the position of the mouse cursor, relative to the widget that received the event. More...
 
QPointF posF () const
 Returns the position of the mouse cursor as a QPointF, relative to the widget that received the event. More...
 
 QMouseEvent (Type type, const QPoint &pos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
 Constructs a mouse event object. More...
 
 QMouseEvent (Type type, const QPoint &pos, const QPoint &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
 Constructs a mouse event object. More...
 
int x () const
 Returns the x position of the mouse cursor, relative to the widget that received the event. More...
 
int y () const
 Returns the y position of the mouse cursor, relative to the widget that received the event. More...
 
 ~QMouseEvent ()
 
- Public Functions inherited from QInputEvent
Qt::KeyboardModifiers modifiers () const
 Returns the keyboard modifier flags that existed immediately before the event occurred. More...
 
 QInputEvent (Type type, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
 
void setModifiers (Qt::KeyboardModifiers amodifiers)
 Sets the keyboard modifiers flags for this event. More...
 
 ~QInputEvent ()
 
- Public Functions inherited from QEvent
void accept ()
 Sets the accept flag of the event object, the equivalent of calling setAccepted(true). More...
 
void ignore ()
 Clears the accept flag parameter of the event object, the equivalent of calling setAccepted(false). More...
 
bool isAccepted () const
 
 QEvent (Type type)
 Contructs an event object of type type. More...
 
void setAccepted (bool accepted)
 
bool spontaneous () const
 Returns true if the event originated outside the application (a system event); otherwise returns false. More...
 
Type type () const
 Returns the event type. More...
 
virtual ~QEvent ()
 Destroys the event. More...
 

Static Public Functions

static QMouseEventcreateExtendedMouseEvent (Type type, const QPointF &pos, const QPoint &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
 
- Static Public Functions inherited from QEvent
static int registerEventType (int hint=-1)
 Registers and returns a custom event type. More...
 

Protected Variables

Qt::MouseButton b
 
QPoint g
 
Qt::MouseButtons mouseState
 
QPoint p
 
- Protected Variables inherited from QInputEvent
Qt::KeyboardModifiers modState
 
- Protected Variables inherited from QEvent
QEventPrivate * d
 
ushort t
 

Additional Inherited Members

- Public Types inherited from QEvent
enum  Type {
  None = 0, Timer = 1, MouseButtonPress = 2, MouseButtonRelease = 3,
  MouseButtonDblClick = 4, MouseMove = 5, KeyPress = 6, KeyRelease = 7,
  FocusIn = 8, FocusOut = 9, Enter = 10, Leave = 11,
  Paint = 12, Move = 13, Resize = 14, Create = 15,
  Destroy = 16, Show = 17, Hide = 18, Close = 19,
  Quit = 20, ParentChange = 21, ParentAboutToChange = 131, ThreadChange = 22,
  WindowActivate = 24, WindowDeactivate = 25, ShowToParent = 26, HideToParent = 27,
  Wheel = 31, WindowTitleChange = 33, WindowIconChange = 34, ApplicationWindowIconChange = 35,
  ApplicationFontChange = 36, ApplicationLayoutDirectionChange = 37, ApplicationPaletteChange = 38, PaletteChange = 39,
  Clipboard = 40, Speech = 42, MetaCall = 43, SockAct = 50,
  WinEventAct = 132, DeferredDelete = 52, DragEnter = 60, DragMove = 61,
  DragLeave = 62, Drop = 63, DragResponse = 64, ChildAdded = 68,
  ChildPolished = 69, ChildRemoved = 71, ShowWindowRequest = 73, PolishRequest = 74,
  Polish = 75, LayoutRequest = 76, UpdateRequest = 77, UpdateLater = 78,
  EmbeddingControl = 79, ActivateControl = 80, DeactivateControl = 81, ContextMenu = 82,
  InputMethod = 83, AccessibilityPrepare = 86, TabletMove = 87, LocaleChange = 88,
  LanguageChange = 89, LayoutDirectionChange = 90, Style = 91, TabletPress = 92,
  TabletRelease = 93, OkRequest = 94, HelpRequest = 95, IconDrag = 96,
  FontChange = 97, EnabledChange = 98, ActivationChange = 99, StyleChange = 100,
  IconTextChange = 101, ModifiedChange = 102, MouseTrackingChange = 109, WindowBlocked = 103,
  WindowUnblocked = 104, WindowStateChange = 105, ToolTip = 110, WhatsThis = 111,
  StatusTip = 112, ActionChanged = 113, ActionAdded = 114, ActionRemoved = 115,
  FileOpen = 116, Shortcut = 117, ShortcutOverride = 51, WhatsThisClicked = 118,
  ToolBarChange = 120, ApplicationActivate = 121, ApplicationActivated = ApplicationActivate, ApplicationDeactivate = 122,
  ApplicationDeactivated = ApplicationDeactivate, QueryWhatsThis = 123, EnterWhatsThisMode = 124, LeaveWhatsThisMode = 125,
  ZOrderChange = 126, HoverEnter = 127, HoverLeave = 128, HoverMove = 129,
  AccessibilityHelp = 119, AccessibilityDescription = 130, AcceptDropsChange = 152, MenubarUpdated = 153,
  ZeroTimerEvent = 154, GraphicsSceneMouseMove = 155, GraphicsSceneMousePress = 156, GraphicsSceneMouseRelease = 157,
  GraphicsSceneMouseDoubleClick = 158, GraphicsSceneContextMenu = 159, GraphicsSceneHoverEnter = 160, GraphicsSceneHoverMove = 161,
  GraphicsSceneHoverLeave = 162, GraphicsSceneHelp = 163, GraphicsSceneDragEnter = 164, GraphicsSceneDragMove = 165,
  GraphicsSceneDragLeave = 166, GraphicsSceneDrop = 167, GraphicsSceneWheel = 168, KeyboardLayoutChange = 169,
  DynamicPropertyChange = 170, TabletEnterProximity = 171, TabletLeaveProximity = 172, NonClientAreaMouseMove = 173,
  NonClientAreaMouseButtonPress = 174, NonClientAreaMouseButtonRelease = 175, NonClientAreaMouseButtonDblClick = 176, MacSizeChange = 177,
  ContentsRectChange = 178, MacGLWindowChange = 179, FutureCallOut = 180, GraphicsSceneResize = 181,
  GraphicsSceneMove = 182, CursorChange = 183, ToolTipChange = 184, NetworkReplyUpdated = 185,
  GrabMouse = 186, UngrabMouse = 187, GrabKeyboard = 188, UngrabKeyboard = 189,
  MacGLClearDrawable = 191, StateMachineSignal = 192, StateMachineWrapped = 193, TouchBegin = 194,
  TouchUpdate = 195, TouchEnd = 196, NativeGesture = 197, RequestSoftwareInputPanel = 199,
  CloseSoftwareInputPanel = 200, UpdateSoftKeys = 201, WinIdChange = 203, Gesture = 198,
  GestureOverride = 202, PlatformPanel = 212, User = 1000, MaxUser = 65535
}
 This enum type defines the valid event types in Qt. More...
 

Detailed Description

The QMouseEvent class contains parameters that describe a mouse event.

Mouse events occur when a mouse button is pressed or released inside a widget, or when the mouse cursor is moved.

Mouse move events will occur only when a mouse button is pressed down, unless mouse tracking has been enabled with QWidget::setMouseTracking().

Qt automatically grabs the mouse when a mouse button is pressed inside a widget; the widget will continue to receive mouse events until the last mouse button is released.

A mouse event contains a special accept flag that indicates whether the receiver wants the event. You should call ignore() if the mouse event is not handled by your widget. A mouse event is propagated up the parent widget chain until a widget accepts it with accept(), or an event filter consumes it.

Note
If a mouse event is propagated to a widget for which Qt::WA_NoMousePropagation has been set, that mouse event will not be propagated further up the parent widget chain.

The state of the keyboard modifier keys can be found by calling the modifiers() function, inherited from QInputEvent.

The functions pos(), x(), and y() give the cursor position relative to the widget that receives the mouse event. If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.

The QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.

Reimplement the QWidget event handlers, QWidget::mousePressEvent(), QWidget::mouseReleaseEvent(), QWidget::mouseDoubleClickEvent(), and QWidget::mouseMoveEvent() to receive mouse events in your own widgets.

See also
QWidget::setMouseTracking() QWidget::grabMouse() QCursor::pos()

Definition at line 85 of file qevent.h.

Constructors and Destructors

◆ QMouseEvent() [1/2]

QMouseEvent::QMouseEvent ( Type  type,
const QPoint position,
Qt::MouseButton  button,
Qt::MouseButtons  buttons,
Qt::KeyboardModifiers  modifiers 
)

Constructs a mouse event object.

The type parameter must be one of QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick, or QEvent::MouseMove.

The position is the mouse cursor's position relative to the receiving widget. The button that caused the event is given as a value from the Qt::MouseButton enum. If the event type is MouseMove , the appropriate button for this event is Qt::NoButton. The mouse and keyboard states at the time of the event are specified by buttons and modifiers.

The globalPos() is initialized to QCursor::pos(), which may not be appropriate. Use the other constructor to specify the global position explicitly.

Definition at line 180 of file qevent.cpp.

Referenced by ~QMouseEvent().

182  : QInputEvent(type, modifiers), p(position), b(button), mouseState(buttons)
183 {
184  g = QCursor::pos();
185 }
QPoint g
Definition: qevent.h:120
Qt::MouseButtons mouseState
Definition: qevent.h:122
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
QInputEvent(Type type, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
Definition: qevent.cpp:77
Qt::MouseButton b
Definition: qevent.h:121
QPoint p
Definition: qevent.h:120
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
Type type() const
Returns the event type.
Definition: qcoreevent.h:303
static QPoint pos()
Returns the position of the cursor (hot spot) in global screen coordinates.
Definition: qcursor_mac.mm:310

◆ QMouseEvent() [2/2]

QMouseEvent::QMouseEvent ( Type  type,
const QPoint pos,
const QPoint globalPos,
Qt::MouseButton  button,
Qt::MouseButtons  buttons,
Qt::KeyboardModifiers  modifiers 
)

Constructs a mouse event object.

The type parameter must be QEvent::MouseButtonPress, QEvent::MouseButtonRelease, QEvent::MouseButtonDblClick, or QEvent::MouseMove.

The pos is the mouse cursor's position relative to the receiving widget. The cursor's position in global coordinates is specified by globalPos. The button that caused the event is given as a value from the Qt::MouseButton enum. If the event type is MouseMove , the appropriate button for this event is Qt::NoButton. buttons is the state of all buttons at the time of the event, modifiers the state of all keyboard modifiers.

Definition at line 242 of file qevent.cpp.

245  : QInputEvent(type, modifiers), p(pos), g(globalPos), b(button), mouseState(buttons)
246 {}
QPoint g
Definition: qevent.h:120
Qt::MouseButtons mouseState
Definition: qevent.h:122
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
QInputEvent(Type type, Qt::KeyboardModifiers modifiers=Qt::NoModifier)
Definition: qevent.cpp:77
Qt::MouseButton b
Definition: qevent.h:121
QPoint p
Definition: qevent.h:120
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ ~QMouseEvent()

QMouseEvent::~QMouseEvent ( )
Warning
This function is not part of the public interface.

Definition at line 190 of file qevent.cpp.

191 {
192 }

Functions

◆ button()

Qt::MouseButton QMouseEvent::button ( ) const
inline

Returns the button that caused the event.

Note that the returned value is always Qt::NoButton for mouse move events.

See also
buttons() Qt::MouseButton

Definition at line 101 of file qevent.h.

Referenced by QStyledItemDelegate::editorEvent(), QItemDelegate::editorEvent(), QStatusBar::event(), QMainWindow::event(), QWidgetResizeHandler::eventFilter(), QVistaHelper::eventFilter(), QAxServerBase::eventFilter(), QWhatsThisPrivate::eventFilter(), QBasicMouseEventTransition::eventTest(), QScriptEdit::extraAreaMouseEvent(), QDockWidgetPrivate::mouseDoubleClickEvent(), QMdiSubWindow::mouseDoubleClickEvent(), QSystemTrayIconSys::mouseDoubleClickEvent(), QLineEdit::mouseDoubleClickEvent(), QGraphicsView::mouseDoubleClickEvent(), QWorkspaceTitleBar::mouseDoubleClickEvent(), QAbstractItemView::mouseDoubleClickEvent(), QMdi::ControlLabel::mouseDoubleClickEvent(), QMenuPrivate::mouseEventTaken(), QGraphicsViewPrivate::mouseMoveEventHandler(), QSizeGrip::mousePressEvent(), QScrollBar::mousePressEvent(), QDial::mousePressEvent(), QMDIControl::mousePressEvent(), QGroupBox::mousePressEvent(), QSlider::mousePressEvent(), QToolButton::mousePressEvent(), QDockWidgetPrivate::mousePressEvent(), QToolBarPrivate::mousePressEvent(), QBalloonTip::mousePressEvent(), QMdiSubWindow::mousePressEvent(), QVistaHelper::mousePressEvent(), QMenuBar::mousePressEvent(), QAbstractButton::mousePressEvent(), QAbstractSpinBox::mousePressEvent(), QWhatsThat::mousePressEvent(), QSystemTrayIconSys::mousePressEvent(), QSplitterHandle::mousePressEvent(), QTabBar::mousePressEvent(), QHeaderView::mousePressEvent(), QLineEdit::mousePressEvent(), QComboBox::mousePressEvent(), QGraphicsView::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QMdi::ControlLabel::mousePressEvent(), QMdi::ControllerWidget::mousePressEvent(), QMdiAreaTabBar::mousePressEvent(), QCalendarView::mousePressEvent(), QSizeGrip::mouseReleaseEvent(), QScrollBar::mouseReleaseEvent(), QDial::mouseReleaseEvent(), QMDIControl::mouseReleaseEvent(), QGroupBox::mouseReleaseEvent(), QDockWidgetPrivate::mouseReleaseEvent(), QMdiSubWindow::mouseReleaseEvent(), QMenuBar::mouseReleaseEvent(), QAbstractButton::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QMenu::mouseReleaseEvent(), QSplitterHandle::mouseReleaseEvent(), QTabBar::mouseReleaseEvent(), QLineEdit::mouseReleaseEvent(), QPlainTextEdit::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QWorkspaceTitleBar::mouseReleaseEvent(), QTextEdit::mouseReleaseEvent(), QMdi::ControlLabel::mouseReleaseEvent(), QMdi::ControllerWidget::mouseReleaseEvent(), QCalendarView::mouseReleaseEvent(), QApplication::notify(), QTriangulator< T >::ComplexToSimple::Event::operator<(), operator<<(), QTextControl::processEvent(), QLineControl::processMouseEvent(), and ~QMouseEvent().

101 { return b; }
Qt::MouseButton b
Definition: qevent.h:121

◆ buttons()

Qt::MouseButton QMouseEvent::buttons ( ) const
inline

Returns the button state when the event was generated.

The button state is a combination of Qt::LeftButton, Qt::RightButton, Qt::MidButton using the OR operator. For mouse move events, this is all buttons that are pressed down. For mouse press and double click events this includes the button that caused the event. For mouse release events this excludes the button that caused the event.

See also
button() Qt::MouseButton

Definition at line 102 of file qevent.h.

Referenced by QMainWindow::event(), QWidgetResizeHandler::eventFilter(), QAxServerBase::eventFilter(), QScriptEdit::extraAreaMouseEvent(), QGraphicsView::mouseDoubleClickEvent(), QMenuPrivate::mouseEventTaken(), QmlJSDebugger::ToolBarColorBox::mouseMoveEvent(), QmlJSDebugger::ZoomTool::mouseMoveEvent(), QSizeGrip::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QDial::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QMenuBar::mouseMoveEvent(), QAbstractButton::mouseMoveEvent(), QmlJSDebugger::AbstractViewInspector::mouseMoveEvent(), QMenu::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QTabBar::mouseMoveEvent(), QHeaderView::mouseMoveEvent(), QLineEdit::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QAbstractItemView::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QmlJSDebugger::ZoomTool::mousePressEvent(), QmlJSDebugger::LiveSelectionTool::mousePressEvent(), QScrollBar::mousePressEvent(), QDial::mousePressEvent(), QSlider::mousePressEvent(), QGraphicsView::mousePressEvent(), QScrollBar::mouseReleaseEvent(), QDial::mouseReleaseEvent(), QSlider::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QApplication::notify(), QTriangulator< T >::ComplexToSimple::Event::operator<(), operator<<(), QTextControl::processEvent(), and QLineControl::processMouseEvent().

102 { return mouseState; }
Qt::MouseButtons mouseState
Definition: qevent.h:122

◆ createExtendedMouseEvent()

QMouseEvent * QMouseEvent::createExtendedMouseEvent ( Type  type,
const QPointF pos,
const QPoint globalPos,
Qt::MouseButton  button,
Qt::MouseButtons  buttons,
Qt::KeyboardModifiers  modifiers 
)
static
Warning
This function is not part of the public interface.

Definition at line 251 of file qevent.cpp.

Referenced by QGraphicsProxyWidgetPrivate::sendWidgetMouseEvent().

254 {
255  return new QMouseEventEx(type, pos, globalPos, button, buttons, modifiers);
256 }
Qt::MouseButton button() const
Returns the button that caused the event.
Definition: qevent.h:101
Qt::MouseButtons buttons() const
Returns the button state when the event was generated.
Definition: qevent.h:102
Qt::KeyboardModifiers modifiers() const
Returns the keyboard modifier flags that existed immediately before the event occurred.
Definition: qevent.h:79
Type type() const
Returns the event type.
Definition: qcoreevent.h:303

◆ globalPos()

const QPoint & QMouseEvent::globalPos ( ) const
inline

Returns the global position of the mouse cursor at the time of the event.

This is important on asynchronous window systems like X11. Whenever you move your widgets around in response to mouse events, globalPos() may differ a lot from the current pointer position QCursor::pos(), and from QWidget::mapToGlobal(pos()).

See also
globalX() globalY()

Definition at line 96 of file qevent.h.

Referenced by QWidgetResizeHandler::eventFilter(), QMdiSubWindow::eventFilter(), QWhatsThisPrivate::eventFilter(), QScriptEdit::extraAreaMouseEvent(), QMenuPrivate::mouseEventTaken(), QSizeGrip::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), QDockWidgetPrivate::mouseMoveEvent(), QToolBarPrivate::mouseMoveEvent(), QTipLabel::mouseMoveEvent(), QSplitterHandle::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QmlJSDebugger::ZoomTool::mousePressEvent(), QSizeGrip::mousePressEvent(), QmlJSDebugger::LiveSelectionTool::mousePressEvent(), QMenuBar::mousePressEvent(), QMenu::mousePressEvent(), QSystemTrayIconSys::mousePressEvent(), QCalendarPopup::mousePressEvent(), QComboBoxPrivateContainer::mousePressEvent(), QMenu::mouseReleaseEvent(), QSplitterHandle::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QApplication::notify(), QTextControl::processEvent(), QTapAndHoldGestureRecognizer::recognize(), QApplicationPrivate::sendMouseEvent(), and ~QMouseEvent().

96 { return g; }
QPoint g
Definition: qevent.h:120

◆ globalX()

int QMouseEvent::globalX ( ) const
inline

Returns the global x position of the mouse cursor at the time of the event.

See also
globalY() globalPos()

Definition at line 99 of file qevent.h.

Referenced by QVistaHelper::eventFilter().

99 { return g.x(); }
QPoint g
Definition: qevent.h:120
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ globalY()

int QMouseEvent::globalY ( ) const
inline

Returns the global y position of the mouse cursor at the time of the event.

See also
globalX() globalPos()

Definition at line 100 of file qevent.h.

Referenced by QVistaHelper::eventFilter().

100 { return g.y(); }
QPoint g
Definition: qevent.h:120
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131

◆ hasExtendedInfo()

bool QMouseEvent::hasExtendedInfo ( ) const
inline
Warning
This function is not part of the public interface.

Definition at line 107 of file qevent.h.

Referenced by posF().

107 { return reinterpret_cast<const QMouseEvent *>(d) == this; }
The QMouseEvent class contains parameters that describe a mouse event.
Definition: qevent.h:85
QEventPrivate * d
Definition: qcoreevent.h:315

◆ pos()

const QPoint & QMouseEvent::pos ( ) const
inline

Returns the position of the mouse cursor, relative to the widget that received the event.

If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.

See also
x() y() globalPos()

Definition at line 95 of file qevent.h.

Referenced by QGraphicsViewPrivate::_q_unsetViewportCursor(), QStyledItemDelegate::editorEvent(), QItemDelegate::editorEvent(), QStatusBar::event(), QMainWindow::event(), QComboBoxPrivateContainer::eventFilter(), QWhatsThisPrivate::eventFilter(), QBasicMouseEventTransition::eventTest(), QScriptEdit::extraAreaMouseEvent(), QmlJSDebugger::LiveSelectionTool::hoverMoveEvent(), QDockWidgetPrivate::mouseDoubleClickEvent(), QTreeView::mouseDoubleClickEvent(), QHeaderView::mouseDoubleClickEvent(), QLineEdit::mouseDoubleClickEvent(), QWorkspaceTitleBar::mouseDoubleClickEvent(), QAbstractItemView::mouseDoubleClickEvent(), QmlJSDebugger::ColorPickerTool::mouseMoveEvent(), QmlJSDebugger::ToolBarColorBox::mouseMoveEvent(), QmlJSDebugger::ZoomTool::mouseMoveEvent(), QmlJSDebugger::LiveSelectionTool::mouseMoveEvent(), QRadioButton::mouseMoveEvent(), QScrollBar::mouseMoveEvent(), QCheckBox::mouseMoveEvent(), QmlJSDebugger::QDeclarativeViewInspector::mouseMoveEvent(), QDial::mouseMoveEvent(), QMDIControl::mouseMoveEvent(), QGroupBox::mouseMoveEvent(), QSlider::mouseMoveEvent(), QDockWidgetPrivate::mouseMoveEvent(), QToolBarPrivate::mouseMoveEvent(), QMdiSubWindow::mouseMoveEvent(), QVistaHelper::mouseMoveEvent(), QMenuBar::mouseMoveEvent(), QAbstractButton::mouseMoveEvent(), QAbstractSpinBox::mouseMoveEvent(), QListView::mouseMoveEvent(), QWhatsThat::mouseMoveEvent(), QMenu::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QTabBar::mouseMoveEvent(), QTreeView::mouseMoveEvent(), QLineEdit::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QGraphicsView::mouseMoveEvent(), QWorkspaceTitleBar::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QColorWell::mouseMoveEvent(), QMdi::ControllerWidget::mouseMoveEvent(), QColorPicker::mouseMoveEvent(), QColorShowLabel::mouseMoveEvent(), QGraphicsViewPrivate::mouseMoveEventHandler(), QmlJSDebugger::ColorPickerTool::mousePressEvent(), QmlJSDebugger::ZoomTool::mousePressEvent(), QmlJSDebugger::LiveSelectionTool::mousePressEvent(), QScrollBar::mousePressEvent(), QDial::mousePressEvent(), QMDIControl::mousePressEvent(), QGroupBox::mousePressEvent(), QSlider::mousePressEvent(), QToolButton::mousePressEvent(), QDockWidgetPrivate::mousePressEvent(), QToolBarPrivate::mousePressEvent(), QMdiSubWindow::mousePressEvent(), QVistaHelper::mousePressEvent(), QMenuBar::mousePressEvent(), QAbstractButton::mousePressEvent(), QAbstractSpinBox::mousePressEvent(), QWellArray::mousePressEvent(), QWhatsThat::mousePressEvent(), QMenu::mousePressEvent(), QCalendarPopup::mousePressEvent(), QSplitterHandle::mousePressEvent(), QDateTimeEdit::mousePressEvent(), QTabBar::mousePressEvent(), QTreeView::mousePressEvent(), QLineEdit::mousePressEvent(), QComboBox::mousePressEvent(), QWorkspaceTitleBar::mousePressEvent(), QColorWell::mousePressEvent(), QMdi::ControllerWidget::mousePressEvent(), QMdiAreaTabBar::mousePressEvent(), QColorPicker::mousePressEvent(), QWidget::mousePressEvent(), QColorShowLabel::mousePressEvent(), QmlJSDebugger::ZoomTool::mouseReleaseEvent(), QmlJSDebugger::LiveSelectionTool::mouseReleaseEvent(), QDial::mouseReleaseEvent(), QMDIControl::mouseReleaseEvent(), QGroupBox::mouseReleaseEvent(), QMdiSubWindow::mouseReleaseEvent(), QVistaHelper::mouseReleaseEvent(), QMenuBar::mouseReleaseEvent(), QAbstractButton::mouseReleaseEvent(), QWhatsThat::mouseReleaseEvent(), QMenu::mouseReleaseEvent(), QTabBar::mouseReleaseEvent(), QTreeView::mouseReleaseEvent(), QLineEdit::mouseReleaseEvent(), QPlainTextEdit::mouseReleaseEvent(), QGraphicsView::mouseReleaseEvent(), QWorkspaceTitleBar::mouseReleaseEvent(), QTextEdit::mouseReleaseEvent(), QMdi::ControllerWidget::mouseReleaseEvent(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QApplication::notify(), QTriangulator< T >::ComplexToSimple::Event::operator<(), posF(), QTextControl::processEvent(), QLineControl::processMouseEvent(), QmlJSDebugger::LiveSelectionTool::selectUnderPoint(), QLineEditPrivate::sendMouseEventToInputContext(), QGraphicsViewPrivate::storeMouseEvent(), and ~QMouseEvent().

95 { return p; }
QPoint p
Definition: qevent.h:120

◆ posF()

QPointF QMouseEvent::posF ( ) const

Returns the position of the mouse cursor as a QPointF, relative to the widget that received the event.

Since
4.4

If you move the widget as a result of the mouse event, use the global position returned by globalPos() to avoid a shaking motion.

See also
x() y() pos() globalPos()

Definition at line 278 of file qevent.cpp.

279 {
280  return hasExtendedInfo() ? reinterpret_cast<const QMouseEventEx *>(this)->posF : QPointF(pos());
281 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
const QPoint & pos() const
Returns the position of the mouse cursor, relative to the widget that received the event...
Definition: qevent.h:95
bool hasExtendedInfo() const
Definition: qevent.h:107
QPointF posF() const
Returns the position of the mouse cursor as a QPointF, relative to the widget that received the event...
Definition: qevent.cpp:278

◆ x()

int QMouseEvent::x ( ) const
inline

Returns the x position of the mouse cursor, relative to the widget that received the event.

See also
y() pos()

Definition at line 97 of file qevent.h.

Referenced by QAxServerBase::eventFilter(), QHeaderView::mouseDoubleClickEvent(), QHeaderView::mouseMoveEvent(), QHeaderView::mousePressEvent(), and QHeaderView::mouseReleaseEvent().

97 { return p.x(); }
QPoint p
Definition: qevent.h:120
int x() const
Returns the x coordinate of this point.
Definition: qpoint.h:128

◆ y()

int QMouseEvent::y ( ) const
inline

Returns the y position of the mouse cursor, relative to the widget that received the event.

See also
x() pos()

Definition at line 98 of file qevent.h.

Referenced by QAxServerBase::eventFilter(), QTreeView::mouseDoubleClickEvent(), QHeaderView::mouseDoubleClickEvent(), QHeaderView::mouseMoveEvent(), QColorLuminancePicker::mouseMoveEvent(), QHeaderView::mousePressEvent(), QColorLuminancePicker::mousePressEvent(), and QHeaderView::mouseReleaseEvent().

98 { return p.y(); }
int y() const
Returns the y coordinate of this point.
Definition: qpoint.h:131
QPoint p
Definition: qevent.h:120

Properties

◆ b

Qt::MouseButton QMouseEvent::b
protected

Definition at line 121 of file qevent.h.

Referenced by ~QMouseEvent().

◆ g

QPoint QMouseEvent::g
protected

Definition at line 120 of file qevent.h.

Referenced by QMouseEvent(), and ~QMouseEvent().

◆ mouseState

Qt::MouseButtons QMouseEvent::mouseState
protected

Definition at line 122 of file qevent.h.

Referenced by ~QMouseEvent().

◆ p

QPoint QMouseEvent::p
protected

Definition at line 120 of file qevent.h.

Referenced by ~QMouseEvent().


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