Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

MouseEvent

Provides information about a mouse event. More...

Import Statement: import QtQuick

Properties

Detailed Description

The position of the mouse can be found via the x and y properties. The button that caused the event is available via the button property.

See also MouseArea.

Property Documentation

[read-only] x : real

[read-only] y : real

These properties hold the coordinates of the position supplied by the mouse event.


accepted : bool

Setting accepted to true prevents the mouse event from being propagated to items below this item.

Generally, if the item acts on the mouse event then it should be accepted so that items lower in the stacking order do not also respond to the same event.


[read-only] button : enumeration

This property holds the button that caused the event. It can be one of:


[read-only] buttons : int

This property holds the mouse buttons pressed when the event was generated. 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.

It contains a bitwise combination of:


[read-only, since 5.11] flags : int

This property holds the flags that provide additional information about the mouse event.

  • Qt.MouseEventCreatedDoubleClick - Indicates that Qt has created a double click event from this event. This flag is set in the event originating from a button press, and not in the resulting double click event.

This property was introduced in Qt 5.11.


[read-only] modifiers : int

This property holds the keyboard modifier flags that existed immediately before the event occurred.

It contains a bitwise combination of:

For example, to react to a Shift key + Left mouse button click:

MouseArea {
    onClicked: (mouse)=> {
        if ((mouse.button == Qt.LeftButton) && (mouse.modifiers & Qt.ShiftModifier))
            doSomething();
    }
}

[read-only] wasHeld : bool

This property is true if the mouse button has been held pressed longer than the threshold (800ms).


Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded