本页内容

WaylandSeat QML Type (Uncreatable)

提供对键盘、鼠标和触摸输入的访问。更多...

Import Statement: import QtWayland.Compositor
In C++: QWaylandSeat

注意:这是一种不可创建的类型。无法在 QML 中对其进行实例化。

信号

方法

详细说明

WaylandSeat 类型提供了对不同类型用户输入的访问,并管理键盘焦点和鼠标指针。它对应于 Wayland 协议中的 wl_seat 接口。

信号文档

void cursorSurfaceRequest(QWaylandSurface surface, int hotspotX, int hotspotY)

当客户端请求将特定的surface 设为鼠标光标时,会触发此信号。例如,当用户将鼠标悬停在某个表面上时,若希望光标变为调整大小箭头。

hotspotX 和hotspotY 都是相对于指针表面左上角的偏移量,点击操作应在此处发生。例如,如果请求的光标表面是一个箭头,则这些参数表示箭头尖端在该表面上的位置。

注意: 对应的处理程序 是onCursorSurfaceRequest 。

void keyboardFocusChanged(QWaylandSurface newFocus, QWaylandSurface oldFocus)

当调用 setKeyboardFocus() 时,或者当某个WaylandQuickItem 拥有焦点且用户开始按键时,会发出此信号。

newFocus 包含接收了键盘焦点的表面;如果没有表面获得焦点,则为nullptr 。oldFocus 包含丢失了键盘焦点的表面;如果没有表面获得焦点,则为nullptr 。

注意: 相应的处理程序 是onKeyboardFocusChanged 。

方法文档

void sendKeyEvent(int qtKey, bool pressed)

向键盘设备发送键qtKey 的按键(若pressed 为true )或释放(若pressed 为false )事件。

void sendTouchCancelEvent(WaylandClient client)

向client 的触摸设备发送一个取消事件。

void sendTouchFrameEvent(WaylandClient client)

向client 的触摸设备发送一个帧事件,以指示一系列向上、向下和移动触摸事件的结束。

void sendTouchPointMoved(WaylandSurface surface, int id, point position)

为位于surface 上的触点id (位置为position )发送一个触摸移动事件。

注意: 在完成触摸事件发送后,您 需要发送一个触摸帧事件。

警告:此 API 不应与使用WaylandQuickItem::touchEventsEnabled 转发触摸事件结合使用,因为这可能会导致触摸 ID 冲突。

返回触摸运动事件的序列号。

uint sendTouchPointPressed(WaylandSurface surface, int id, point position)

为位于surface 上、坐标为position 的触点id 发送一个触摸按下事件。

注意: 在完成触摸事件的发送后,您 需要发送一个触摸帧事件。

警告: 不应将此 API 与使用WaylandQuickItem::touchEventsEnabled 转发触摸事件结合使用,因为这可能会导致触摸 ID 冲突。

返回触摸按下事件的序列号。

void sendTouchPointReleased(WaylandSurface surface, int id, point position)

为位于surface 且位置为position 的触点id 发送一个触摸释放事件。

注意: 在完成触摸事件的发送后,您 需要发送一个触摸帧事件。

警告: 不应将此 API 与使用WaylandQuickItem::touchEventsEnabled 转发触摸事件结合使用,因为这可能会导致触摸 ID 冲突。

返回触摸释放事件的序列号。

[since 6.7] void sendUnicodeKeyPressEvent(uint unicode)

通过文本输入协议发送 UCS4unicode 的按键事件。

注意: 如果客户端不支持合成器所支持的文本输入协议,则此 函数将无法正常工作。

该方法于 Qt 6.7 中引入。

[since 6.7] void sendUnicodeKeyReleaseEvent(uint unicode)

通过文本输入协议发送 UCS4unicode 的键释放事件。

注意: 如果客户端不支持合成器所支持的文本输入协议,则此 函数将无法正常工作。

该方法于 Qt 6.7 中引入。

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