QWaylandSurfaceRole Class
QWaylandSurfaceRole 类表示曲面在 wl_surface 上下文中的角色。更多
Header: | #include <QWaylandSurfaceRole> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor) target_link_libraries(mytarget PRIVATE Qt6::WaylandCompositor) |
qmake: | QT += waylandcompositor |
公共函数
QWaylandSurfaceRole(const QByteArray &name) | |
const QByteArray | name() |
详细说明
QWaylandSurfaceRole 用于表示QWaylandSurface 的角色。根据协议规范,曲面的角色一经设置即为永久性的,如果同一曲面后来被重新用于不同的角色,则构成协议错误。多次将曲面设置为同一角色不会出错。
例如,QWaylandXdgShell 可以为曲面指定 "弹出 "或 "顶层 "角色。如果get_toplevel
被请求到一个之前已接收过get_popup
请求的曲面上,那么合成器将发出协议错误。
角色是通过指针值进行比较的,因此任何两个 QWaylandSurfaceRole 对象都将被视为不同的角色,无论它们的names 是什么。分配角色的典型方法是使用静态 QWaylandSurfaceRole 对象来表示它。
class MyShellSurfaceSubType { static QWaylandSurfaceRole s_role; // ... }; // ... surface->setRole(&MyShellSurfaceSubType::s_role, resource->handle, MY_ERROR_CODE);
成员函数文档
QWaylandSurfaceRole::QWaylandSurfaceRole(const QByteArray &name)
创建 QWaylandSurfaceRole 并为其分配name 。该名称会在涉及该 QWaylandSurfaceRole 的错误信息中使用。
const QByteArray QWaylandSurfaceRole::name()
返回QWaylandSurfaceRole 的名称。该名称会在涉及QWaylandSurfaceRole 的错误信息中使用,例如在试图更改曲面的角色时。
© 2025 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.