QWaylandQuickShellIntegration Class

Provides support for shell surface integration with QtQuick . 更多...

头: #include <QWaylandQuickShellIntegration>
qmake: QT += waylandcompositor
Since: Qt 5.14
继承: QObject

该类在 Qt 5.14 引入。

详细描述

Shell surface implementations should inherit from this class in order to provide an integration between the shell surface and QtQuick .

Shell integration is installed as an event filter for a QWaylandQuickShellSurfaceItem . Reimplement the event filter method and return true when you want to filter the event out, otherwise return false .

范例:

class MyShellIntegration : public QWaylandQuickShellIntegration
{
    Q_OBJECT
public:
    MyShellIntegration(QObject *parent = nullptr);
protected:
    bool eventFilter(QObject *object, QEvent *event) override;
};
MyShellIntegration::MyShellIntegration(QObject *parent)
    : QWaylandQuickShellIntegration(parent)
{
}
bool MyShellIntegration::eventFilter(QObject *object, QEvent *event)
{
    QWaylandQuickShellSurfaceItem *shellSurfaceItem = qobject_cast<QWaylandQuickShellSurfaceItem *>(object);
    if (!shellSurfaceItem)
        return QWaylandQuickShellIntegration::eventFilter(object, event);
    if (event->type() == QEvent::MouseMove) {
        QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
        qDebug() << "Mouse moved on" << shellSurfaceItem << "pos:" << mouseEvent->pos();
        return true;
    }
    return QWaylandQuickShellIntegration::eventFilter(object, event);
}
					

另请参阅 QWaylandQuickShellSurfaceItem and QObject::eventFilter ().