Handling mouse and touch events
QML provides excellent support for mouse and touch events through input handlers that let QML applications handle mouse and touch events. QML types such as MouseArea
, MultiPointTouchArea
, and TapHandler
are used to detect mouse and touch events. We will have a look at these QML types in the following section.
MouseArea
MouseArea
is an invisible item that is used with a visible item such as Item
or Rectangle
in order to provide mouse and touch handling events for that item. MouseArea
receives mouse events within the defined area of Item
. You can define this area by anchoring MouseArea
to its parent's area using the anchors.fill
property. If you set the visible property to false
, then the mouse area becomes transparent to mouse events.
Let's look at how to use MouseArea
in the following example:
import QtQuick import QtQuick.Window Window { width: 640; height: 480 visible: true ...