本页内容

QWaylandQuickShellIntegration Class

支持与QtQuick 的Shell表面集成。更多内容...

标题: #include <QWaylandQuickShellIntegration>
CMake: find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor)
target_link_libraries(mytarget PRIVATE Qt6::WaylandCompositor)
qmake: QT += waylandcompositor
继承自: QObject

详细说明

Shell表面实现应继承自该类,以便在Shell表面与QtQuick 之间实现集成。

Shell集成将作为QWaylandQuickShellSurfaceItem 的事件过滤器进行安装。当需要过滤该事件时,请重写事件过滤器方法并返回true ;否则,请返回false 。

示例:

classMyShellIntegration :publicQWaylandQuickShellIntegration
{
    Q_OBJECT
public:
    MyShellIntegration(QObject*parent =nullptr);

protected:
    booleventFilter(QObject*object,QEvent*event) override;
};

MyShellIntegration::MyShellIntegration(QObject*parent)
    : QWaylandQuickShellIntegration(parent)
{
}

boolMyShellIntegration::eventFilter(QObject*object,QEvent*event)
{
    QWaylandQuickShellSurfaceItem*shellSurfaceItem =qobject_cast<QWaylandQuickShellSurfaceItem*>(object);
    if(!shellSurfaceItem)
        returnQWaylandQuickShellIntegration::eventFilter(object,event);

    if(event->type()==QEvent::MouseMove) {
        QMouseEvent*mouseEvent = static_cast<QMouseEvent*>(event);
        qDebug() << "Mouse moved on" << shellSurfaceItem << "pos:" << mouseEvent->pos();
       return true;
    }

    returnQWaylandQuickShellIntegration::eventFilter(object,event);
}

另请参阅 QWaylandQuickShellSurfaceItem 和QObject::eventFilter()。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.