Make window transparent to mouse events outside MouseAreas?
Unsolved
QML and Qt Quick
-
I know I might have some crazy ideas but I decide to share with you guys.
Basically I'm making a frameless semi-transparent application with QML. There are some buttons based on MouseArea that I want to click. Besides the buttons are some other (semi-transparent) visual components but I want them to ignore any mouse events (so that I can click at other applications below them).
Is this possible with the current QML framework (or in c++ side)?
Things I've tried so far:
-
Qt.WA_TransparentForMouseEvents
. This sadly make my window ignore all mouse events and there doesn't seem to be anyway to catch them. -
setMask
onQWindow
orQQuickWidget
. The mask can correctly limit mouse event capturing but it also crops all visual contents.
Some sample code:
import QtQuick 2.8 Rectangle { // click through this color: Qt.rgba(1, 1, 1, 0.5) width: 640 height: 480 Rectangle { // click on this color: 'white' width: 50 height: 50 anchors.centerIn: parent MouseArea { anchors.fill: parent onClicked: console.log('click') } } }
-