import QtQuick 2.9 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") MouseArea { width: parent.width/2 height: parent.height/2 acceptedButtons: Qt.LeftButton | Qt.RightButton onPressed: { if (mouse.button === Qt.LeftButton) { console.log("pressed left"); } else if (mouse.button === Qt.RightButton) { console.log("pressed right"); } } onReleased: { if (mouse.button === Qt.LeftButton) { console.log("released left"); } else if (mouse.button === Qt.RightButton) { console.log("released right"); } } } }