Rasppberry 上的 QML 应用程序,鼠标事件传递到 Raspbian 桌面

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

我开发了一个简单的 QML 应用程序,并且我 运行 在目标设备(带触摸屏的 RPI)上进行 cross 编译。

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
    }
}

让我困惑的问题是,当我触摸应用程序中的任何地方时,底层桌面(RPI 桌面)也会被触摸。这意味着所有鼠标或触摸事件都转发到后屏幕,即 Raspbian 桌面。

这是我的示例代码。 (不是代码问题,我觉得应该和EGLFS或者os里的其他东西有关)

如有任何提示,我们将不胜感激。

更新:

我发现只有当我 运行 带有“-platform eglfs”参数的应用程序时才会出现问题。

更新 2: 我用 RPI4 测试过,似乎问题只存在于 RPI3

eglfs 平台适用于 运行宁 没有 window 系统。如果您在 Raspbian 桌面上,那不是 X 服务器 运行ning 吗?所以你应该让 Qt 为 window 系统(xcb 或 wayland)选择合适的插件。您仍然可以使用 QWindow::setVisibility() 强制应用程序全屏显示。或者,如果您想使用 eglfs 在虚拟控制台上部署嵌入式全屏应用程序和 运行,请终止 window 系统。那样会更轻。