6.0.0-rc4Source

QMouseEvent Class

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

Header#include <QMouseEvent>
CMaketarget_link_libraries(app PRIVATE Nt::Gui)
ModuleNt GUI C++ Classes
InheritsQInputEvent

List of all members, including inherited members

Public Functions

QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)
Qt::MouseButtonbutton() const
Qt::MouseButtonsbuttons() const
QPointFposition() const
QPointFglobalPosition() const
QPointpos() const
QPointglobalPos() const
intx() const
inty() const

Reimplemented Public Functions

QMouseEvent *clone() const

Detailed Description

Mouse events arrive when a mouse button is pressed or released (MouseButtonPress, MouseButtonRelease, MouseButtonDblClick) and when the mouse moves (MouseMove). Windows receive them in QWindow::mousePressEvent() and the related functions.

See also QWindow and QWheelEvent.

Differences from Qt

Positions are in the coordinates of the window and its screen only; there is no scene position, source device or synthesized flag.

Member Function Documentation

QMouseEvent::QMouseEvent(Type type, const QPointF &localPos, const QPointF &globalPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers)

Constructs a mouse event of the given type. localPos is the position in the receiving window and globalPos the position on the screen. button is the button that caused the event, buttons the buttons that are down, and modifiers the modifier keys.

Qt::MouseButton QMouseEvent::button() const

Returns the button that caused the event, or Qt::NoButton for a move.

Qt::MouseButtons QMouseEvent::buttons() const

Returns the buttons that were down when the event happened.

[override] QMouseEvent * QMouseEvent::clone() const

Reimplements QInputEvent::clone().

QPoint QMouseEvent::globalPos() const

Returns globalPosition() as an integer point.

QPointF QMouseEvent::globalPosition() const

Returns the position of the mouse on the screen.

QPoint QMouseEvent::pos() const

Returns position() as an integer point.

QPointF QMouseEvent::position() const

Returns the position of the mouse in the receiving window.

int QMouseEvent::x() const

Returns the x coordinate of pos().

int QMouseEvent::y() const

Returns the y coordinate of pos().