[][src]Struct qt_gui::QMouseEvent

#[repr(C)]
pub struct QMouseEvent { /* fields omitted */ }

The QMouseEvent class contains parameters that describe a mouse event.

C++ class: QMouseEvent.

C++ documentation:

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.

Methods

impl QMouseEvent[src]

pub unsafe fn button(&self) -> MouseButton[src]

Returns the button that caused the event.

Calls C++ function: Qt::MouseButton QMouseEvent::button() const.

C++ documentation:

Returns the button that caused the event.

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

See also buttons() and Qt::MouseButton.

pub unsafe fn buttons(&self) -> QFlags<MouseButton>[src]

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.

Calls C++ function: QFlags<Qt::MouseButton> QMouseEvent::buttons() const.

C++ documentation:

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() and Qt::MouseButton.

pub unsafe fn copy_from(
    &mut self,
    other: impl CastInto<Ref<QMouseEvent>>
) -> MutRef<QMouseEvent>
[src]

The QMouseEvent class contains parameters that describe a mouse event.

Calls C++ function: QMouseEvent& QMouseEvent::operator=(const QMouseEvent& other).

C++ documentation:

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.

pub unsafe fn flags(&self) -> QFlags<MouseEventFlag>[src]

Returns the mouse event flags.

Calls C++ function: QFlags<Qt::MouseEventFlag> QMouseEvent::flags() const.

C++ documentation:

Returns the mouse event flags.

The mouse event flags provide additional information about a mouse event.

This function was introduced in Qt 5.3.

See also Qt::MouseEventFlag and QGraphicsSceneMouseEvent::flags().

pub unsafe fn global_pos(&self) -> CppBox<QPoint>[src]

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()).

Calls C++ function: QPoint QMouseEvent::globalPos() const.

C++ documentation:

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() and globalY().

pub unsafe fn global_x(&self) -> c_int[src]

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

Calls C++ function: int QMouseEvent::globalX() const.

C++ documentation:

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

See also globalY() and globalPos().

pub unsafe fn global_y(&self) -> c_int[src]

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

Calls C++ function: int QMouseEvent::globalY() const.

C++ documentation:

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

See also globalX() and globalPos().

pub unsafe fn local_pos(&self) -> Ref<QPointF>[src]

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

Calls C++ function: const QPointF& QMouseEvent::localPos() const.

C++ documentation:

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

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

This function was introduced in Qt 5.0.

See also x(), y(), windowPos(), and screenPos().

pub unsafe fn new_5a(
    type_: Type,
    local_pos: impl CastInto<Ref<QPointF>>,
    button: MouseButton,
    buttons: QFlags<MouseButton>,
    modifiers: QFlags<KeyboardModifier>
) -> CppBox<QMouseEvent>
[src]

Constructs a mouse event object.

Calls C++ function: [constructor] void QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF& localPos, Qt::MouseButton button, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers).

C++ documentation:

Constructs a mouse event object.

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

The localPos is the mouse cursor's position relative to the receiving widget or item. The window position is set to the same value as localPos. 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 screenPos() is initialized to QCursor::pos(), which may not be appropriate. Use the other constructor to specify the global position explicitly.

pub unsafe fn new_6a(
    type_: Type,
    local_pos: impl CastInto<Ref<QPointF>>,
    screen_pos: impl CastInto<Ref<QPointF>>,
    button: MouseButton,
    buttons: QFlags<MouseButton>,
    modifiers: QFlags<KeyboardModifier>
) -> CppBox<QMouseEvent>
[src]

Constructs a mouse event object.

Calls C++ function: [constructor] void QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF& localPos, const QPointF& screenPos, Qt::MouseButton button, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers).

C++ documentation:

Constructs a mouse event object.

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

The localPos is the mouse cursor's position relative to the receiving widget or item. The cursor's position in screen coordinates is specified by screenPos. The window position is set to the same value as localPos. 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.

pub unsafe fn new_7a(
    type_: Type,
    local_pos: impl CastInto<Ref<QPointF>>,
    window_pos: impl CastInto<Ref<QPointF>>,
    screen_pos: impl CastInto<Ref<QPointF>>,
    button: MouseButton,
    buttons: QFlags<MouseButton>,
    modifiers: QFlags<KeyboardModifier>
) -> CppBox<QMouseEvent>
[src]

Constructs a mouse event object.

Calls C++ function: [constructor] void QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF& localPos, const QPointF& windowPos, const QPointF& screenPos, Qt::MouseButton button, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers).

C++ documentation:

Constructs a mouse event object.

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

The points localPos, windowPos and screenPos specify the mouse cursor's position relative to the receiving widget or item, window, and screen, respectively.

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.

pub unsafe fn new_8a(
    type_: Type,
    local_pos: impl CastInto<Ref<QPointF>>,
    window_pos: impl CastInto<Ref<QPointF>>,
    screen_pos: impl CastInto<Ref<QPointF>>,
    button: MouseButton,
    buttons: QFlags<MouseButton>,
    modifiers: QFlags<KeyboardModifier>,
    source: MouseEventSource
) -> CppBox<QMouseEvent>
[src]

Default constructs an instance of QMouseEvent.

Calls C++ function: [constructor] void QMouseEvent::QMouseEvent(QEvent::Type type, const QPointF& localPos, const QPointF& windowPos, const QPointF& screenPos, Qt::MouseButton button, QFlags<Qt::MouseButton> buttons, QFlags<Qt::KeyboardModifier> modifiers, Qt::MouseEventSource source).

C++ documentation:

Default constructs an instance of QMouseEvent.

pub unsafe fn new_copy(
    other: impl CastInto<Ref<QMouseEvent>>
) -> CppBox<QMouseEvent>
[src]

The QMouseEvent class contains parameters that describe a mouse event.

Calls C++ function: [constructor] void QMouseEvent::QMouseEvent(const QMouseEvent& other).

C++ documentation:

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.

pub unsafe fn pos(&self) -> CppBox<QPoint>[src]

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

Calls C++ function: QPoint QMouseEvent::pos() const.

C++ documentation:

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(), and globalPos().

pub unsafe fn screen_pos(&self) -> Ref<QPointF>[src]

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

Calls C++ function: const QPointF& QMouseEvent::screenPos() const.

C++ documentation:

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

This function was introduced in Qt 5.0.

See also x(), y(), pos(), localPos(), and windowPos().

pub unsafe fn set_local_pos(
    &mut self,
    local_position: impl CastInto<Ref<QPointF>>
)
[src]

Calls C++ function: void QMouseEvent::setLocalPos(const QPointF& localPosition).

pub unsafe fn source(&self) -> MouseEventSource[src]

Returns information about the mouse event source.

Calls C++ function: Qt::MouseEventSource QMouseEvent::source() const.

C++ documentation:

Returns information about the mouse event source.

The mouse event source can be used to distinguish between genuine and artificial mouse events. The latter are events that are synthesized from touch events by the operating system or Qt itself.

Note: Many platforms provide no such information. On such platforms Qt::MouseEventNotSynthesized is returned always.

This function was introduced in Qt 5.3.

See also Qt::MouseEventSource and QGraphicsSceneMouseEvent::source().

pub unsafe fn window_pos(&self) -> Ref<QPointF>[src]

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

Calls C++ function: const QPointF& QMouseEvent::windowPos() const.

C++ documentation:

Returns the position of the mouse cursor as a QPointF, relative to the window 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.

This function was introduced in Qt 5.0.

See also x(), y(), pos(), localPos(), and screenPos().

pub unsafe fn x(&self) -> c_int[src]

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

Calls C++ function: int QMouseEvent::x() const.

C++ documentation:

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

See also y() and pos().

pub unsafe fn y(&self) -> c_int[src]

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

Calls C++ function: int QMouseEvent::y() const.

C++ documentation:

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

See also x() and pos().

Methods from Deref<Target = QInputEvent>

pub unsafe fn copy_from(
    &mut self,
    other: impl CastInto<Ref<QInputEvent>>
) -> MutRef<QInputEvent>
[src]

The QInputEvent class is the base class for events that describe user input.

Calls C++ function: QInputEvent& QInputEvent::operator=(const QInputEvent& other).

C++ documentation:

The QInputEvent class is the base class for events that describe user input.

pub unsafe fn modifiers(&self) -> QFlags<KeyboardModifier>[src]

Returns the keyboard modifier flags that existed immediately before the event occurred.

Calls C++ function: QFlags<Qt::KeyboardModifier> QInputEvent::modifiers() const.

C++ documentation:

Returns the keyboard modifier flags that existed immediately before the event occurred.

See also QGuiApplication::keyboardModifiers().

pub unsafe fn set_modifiers(&mut self, amodifiers: QFlags<KeyboardModifier>)[src]

Calls C++ function: void QInputEvent::setModifiers(QFlags<Qt::KeyboardModifier> amodifiers).

pub unsafe fn set_timestamp(&mut self, atimestamp: c_ulong)[src]

Calls C++ function: void QInputEvent::setTimestamp(unsigned long atimestamp).

pub unsafe fn timestamp(&self) -> c_ulong[src]

Returns the window system's timestamp for this event. It will normally be in milliseconds since some arbitrary point in time, such as the time when the system was started.

Calls C++ function: unsigned long QInputEvent::timestamp() const.

C++ documentation:

Returns the window system's timestamp for this event. It will normally be in milliseconds since some arbitrary point in time, such as the time when the system was started.

Trait Implementations

impl CppDeletable for QMouseEvent[src]

unsafe fn delete(&mut self)[src]

Calls C++ function: virtual [destructor] void QMouseEvent::~QMouseEvent().

impl Deref for QMouseEvent[src]

type Target = QInputEvent

The resulting type after dereferencing.

fn deref(&self) -> &QInputEvent[src]

Calls C++ function: QInputEvent* static_cast<QInputEvent*>(QMouseEvent* ptr).

impl DerefMut for QMouseEvent[src]

fn deref_mut(&mut self) -> &mut QInputEvent[src]

Calls C++ function: QInputEvent* static_cast<QInputEvent*>(QMouseEvent* ptr).

impl DynamicCast<QMouseEvent> for QInputEvent[src]

unsafe fn dynamic_cast(ptr: Ptr<QInputEvent>) -> Ptr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* dynamic_cast<QMouseEvent*>(QInputEvent* ptr).

unsafe fn dynamic_cast_mut(ptr: MutPtr<QInputEvent>) -> MutPtr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* dynamic_cast<QMouseEvent*>(QInputEvent* ptr).

impl DynamicCast<QMouseEvent> for QEvent[src]

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* dynamic_cast<QMouseEvent*>(QEvent* ptr).

unsafe fn dynamic_cast_mut(ptr: MutPtr<QEvent>) -> MutPtr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* dynamic_cast<QMouseEvent*>(QEvent* ptr).

impl StaticDowncast<QMouseEvent> for QInputEvent[src]

unsafe fn static_downcast(ptr: Ptr<QInputEvent>) -> Ptr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* static_cast<QMouseEvent*>(QInputEvent* ptr).

unsafe fn static_downcast_mut(ptr: MutPtr<QInputEvent>) -> MutPtr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* static_cast<QMouseEvent*>(QInputEvent* ptr).

impl StaticDowncast<QMouseEvent> for QEvent[src]

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* static_cast<QMouseEvent*>(QEvent* ptr).

unsafe fn static_downcast_mut(ptr: MutPtr<QEvent>) -> MutPtr<QMouseEvent>[src]

Calls C++ function: QMouseEvent* static_cast<QMouseEvent*>(QEvent* ptr).

impl StaticUpcast<QEvent> for QMouseEvent[src]

unsafe fn static_upcast(ptr: Ptr<QMouseEvent>) -> Ptr<QEvent>[src]

Calls C++ function: QEvent* static_cast<QEvent*>(QMouseEvent* ptr).

unsafe fn static_upcast_mut(ptr: MutPtr<QMouseEvent>) -> MutPtr<QEvent>[src]

Calls C++ function: QEvent* static_cast<QEvent*>(QMouseEvent* ptr).

impl StaticUpcast<QInputEvent> for QMouseEvent[src]

unsafe fn static_upcast(ptr: Ptr<QMouseEvent>) -> Ptr<QInputEvent>[src]

Calls C++ function: QInputEvent* static_cast<QInputEvent*>(QMouseEvent* ptr).

unsafe fn static_upcast_mut(ptr: MutPtr<QMouseEvent>) -> MutPtr<QInputEvent>[src]

Calls C++ function: QInputEvent* static_cast<QInputEvent*>(QMouseEvent* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.