'QML Application on Rasppberry, Mouse events are passed to the Raspbian Desktop

I have developed a simple QML application and I run with cross-compiling on the target device (RPI with a touchscreen).

import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12

Window {
    width: 640
    height: 480
    visible: true
    title: qsTr("Hello World")

    // Not helping
    MouseArea {
        anchors.fill: parent;
        hoverEnabled: true
    }

    Button {
        text: "quit";
        onClicked: Qt.quit()
        anchors.centerIn: parent;
        width: 300
        height: 250
    }
}

The problem that is confused me is that when I touch anywhere in the application, the underlying desktop (RPI desktop) is also touched. It means that all mouse or touch events are forwarded to the back screen which is Raspbian Desktop.

This is my sample code. (it's not the code issue. I think it should be related to EGLFS or something else in the os)

Any hints will be appreciated.

UPDATE:

I found that the problem occurred only if I run the app with "-platform eglfs" arguments.

UPDATE 2: I tested with RPI4 and it seems the problem only existed with RPI3



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source