本页内容

QWaylandCompositorExtensionTemplate Class

template <typename T> class QWaylandCompositorExtensionTemplate

QWaylandCompositorExtensionTemplate 是一个用于继承QWaylandCompositorExtension 的便捷类。更多内容...

头文件: #include <QWaylandCompositorExtensionTemplate>
CMake: find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor)
target_link_libraries(mytarget PRIVATE Qt6::WaylandCompositor)
qmake: QT += waylandcompositor
继承自: QWaylandCompositorExtension
被继承者:

QWaylandIdleInhibitManagerV1、QWaylandIviApplication 、QWaylandQtTextInputMethodManager 、QWaylandTextInputManager 、QWaylandViewporter 、QWaylandXdgDecorationManagerV1 ,以及QWaylandXdgOutputManagerV1

静态公共成员

T *findIn(QWaylandObject *container)

详细说明

QWaylandCompositorExtensionTemplate 是一个继承自QWaylandCompositorExtension 的模板类,便于使用 Qt 构建自定义的 Wayland 扩展。

它基于扩展协议的 XML 描述,在Qt Wayland Compositor 与qtwaylandscanner 生成的类之间建立了连接。

它提供了两项具体的便利功能:

  • 对 `QWaylandCompositorExtension::extensionInterface()` 的重写,该方法返回由 `qtwaylandscanner` 生成的基类的 `wl_interface ` 指针。
  • 一个静态函数findIn(),用于在给定的容器中搜索该扩展的实例,若找到则返回该实例。

通常,新的扩展类会双重继承 QWaylandCompositorExtensionTemplate 和由qtwaylandscanner 生成的类。

应将T 作为子类本身作为参数传递给QWaylandCompositorExtensionTemplate:

class MyExtension
    : public QWaylandCompositorExtensionTemplate<MyExtension>
    , QtWaylandServer::my_extension

在此示例中,MyExtension 是生成的接口my_extension 的实现。

另请参阅 “自定义 Shell”。

成员函数文档

[static] T *QWaylandCompositorExtensionTemplate::findIn(QWaylandObject *container)

如果该接口的任何实例已通过container 进行注册,则返回该实例;否则返回null。查找操作基于生成的interfaceName() ,该文件与协议描述中的接口名称相匹配。

© 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.