QWaylandSeat Class
QWaylandSeat 类提供对键盘、鼠标和触摸输入的访问。更多
头文件: | #include <QWaylandSeat> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS WaylandCompositor) target_link_libraries(mytarget PRIVATE Qt6::WaylandCompositor) |
qmake: | QT += waylandcompositor |
在 QML 中: | WaylandSeat |
继承: | QWaylandObject |
公共类型
enum | CapabilityFlag { Pointer, Keyboard, Touch, DefaultCapabilities } |
flags | CapabilityFlags |
属性
公共功能
QWaylandSeat(QWaylandCompositor *compositor, QWaylandSeat::CapabilityFlags capabilityFlags = DefaultCapabilities) | |
virtual | ~QWaylandSeat() override |
QWaylandSeat::CapabilityFlags | capabilities() const |
QWaylandCompositor * | compositor() const |
QWaylandDrag * | drag() const |
virtual void | initialize() |
bool | isInitialized() const |
QWaylandKeyboard * | keyboard() const |
QWaylandSurface * | keyboardFocus() const |
QWaylandKeymap * | keymap() |
QWaylandView * | mouseFocus() const |
QWaylandPointer * | pointer() const |
void | sendFullKeyEvent(QKeyEvent *event) |
void | sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *event) |
void | sendKeyEvent(int qtKey, bool pressed) |
void | sendKeyPressEvent(uint code) |
void | sendKeyReleaseEvent(uint code) |
void | sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos = QPointF()) |
void | sendMousePressEvent(Qt::MouseButton button) |
void | sendMouseReleaseEvent(Qt::MouseButton button) |
void | sendMouseWheelEvent(Qt::Orientation orientation, int delta) |
void | sendTouchCancelEvent(QWaylandClient *client) |
void | sendTouchFrameEvent(QWaylandClient *client) |
uint | sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state) |
uint | sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position) |
uint | sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position) |
uint | sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position) |
(since 6.7) void | sendUnicodeKeyPressEvent(uint unicode) |
(since 6.7) void | sendUnicodeKeyReleaseEvent(uint unicode) |
bool | setKeyboardFocus(QWaylandSurface *surface) |
void | setMouseFocus(QWaylandView *view) |
QWaylandTouch * | touch() const |
信号
void | cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY) |
void | keyboardFocusChanged(QWaylandSurface *newFocus, QWaylandSurface *oldFocus) |
void | mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus) |
静态公共成员
QWaylandSeat * | fromSeatResource(struct wl_resource *resource) |
成员类型文档
枚举 QWaylandSeat::CapabilityFlag
flags QWaylandSeat::CapabilityFlags
该枚举类型描述了QWaylandSeat 的能力。
常量 | 值 | 描述 |
---|---|---|
QWaylandSeat::Pointer | 0x01 | QWaylandSeat 支持指针输入。 |
QWaylandSeat::Keyboard | 0x02 | QWaylandSeat 支持键盘输入。 |
QWaylandSeat::Touch | 0x04 | QWaylandSeat 支持触摸输入。 |
QWaylandSeat::DefaultCapabilities | Pointer | Keyboard | Touch | QWaylandSeat 具有默认功能。 |
CapabilityFlags 类型是QFlags<CapabilityFlag> 的类型定义。它存储 CapabilityFlag 值的 OR 组合。
属性文档
[read-only]
drag : QWaylandDrag* const
该属性保存拖放操作,并在操作开始和结束时发送信号。该属性存储用户拖动时鼠标光标下应显示的图像等详细信息。
访问功能:
QWaylandDrag * | drag() const |
[read-only]
keymap : QWaylandKeymap* const
该属性包含键表对象。
键表提供了一种将实际按键扫描代码转换为有意义值的方法。例如,如果使用挪威文布局的键图,字母 L 右边的键就会产生一个 Ø。
键位图还可用于自定义按键功能,例如指定是否要交换 Control 键和 CAPS 锁等。
访问功能:
QWaylandKeymap * | keymap() |
成员函数文档
QWaylandSeat::QWaylandSeat(QWaylandCompositor *compositor, QWaylandSeat::CapabilityFlags capabilityFlags = DefaultCapabilities)
为给定的compositor 和capabilityFlags 构建一个 QWaylandSeat。
[override virtual noexcept]
QWaylandSeat::~QWaylandSeat()
QWaylandSeat::CapabilityFlags QWaylandSeat::capabilities() const
返回该QWaylandSeat 的能力标志。
QWaylandCompositor *QWaylandSeat::compositor() const
返回QWaylandSeat 的合成器。
[signal]
void QWaylandSeat::cursorSurfaceRequest(QWaylandSurface *surface, int hotspotX, int hotspotY)
当客户端请求将特定surface 作为鼠标光标时,就会发出该信号。例如,当用户将鼠标悬停在某一特定表面上,并希望光标变成一个调整大小的箭头时。
hotspotX 和hotspotY 都是指针表面左上角的偏移量,点击时应该发生在左上角。例如,如果请求的光标表面是一个箭头,参数则表示箭头尖端在该表面上的位置。
QWaylandDrag *QWaylandSeat::drag() const
返回此QWaylandSeat 的拖动对象。
注: 属性拖动的获取函数。
[static]
QWaylandSeat *QWaylandSeat::fromSeatResource(struct wl_resource *resource)
返回与resource 对应的QWaylandSeat 。预计resource 的类型为 wl_seat。
[virtual]
void QWaylandSeat::initialize()
根据在构造函数中或通过 setCapabilities() 设置的功能,初始化座椅的相应部分。
注: 通常情况下,该函数会在座位和合成器创建完成后自动调用,因此通常无需手动调用。
bool QWaylandSeat::isInitialized() const
如果QWaylandSeat 已初始化,则返回 true;否则返回 false。
true
表示客户现在可以开始使用席位。
QWaylandKeyboard *QWaylandSeat::keyboard() const
返回此输入设备的键盘。
QWaylandSurface *QWaylandSeat::keyboardFocus() const
返回当前键盘输入的焦点表面。
另请参阅 setKeyboardFocus()。
[signal]
void QWaylandSeat::keyboardFocusChanged(QWaylandSurface *newFocus, QWaylandSurface *oldFocus)
调用setKeyboardFocus() 时会发出该信号。
newFocus nullptr
oldFocus 是失去键盘焦点的表面;或 是没有焦点的表面。nullptr
QWaylandKeymap *QWaylandSeat::keymap()
返回QWaylandSeat 的键表对象。
注: 键映射属性的获取函数。
QWaylandView *QWaylandSeat::mouseFocus() const
返回当前拥有鼠标焦点的视图。
另请参阅 setMouseFocus()。
[signal]
void QWaylandSeat::mouseFocusChanged(QWaylandView *newFocus, QWaylandView *oldFocus)
当鼠标焦点从oldFocus 变为newFocus 时,将发出该信号。
QWaylandPointer *QWaylandSeat::pointer() const
返回QWaylandSeat 的指针设备。
void QWaylandSeat::sendFullKeyEvent(QKeyEvent *event)
将event 发送至键盘设备。
注意: event 应与当前映射中的实际键盘键相对应。例如,Qt::Key_Exclam
通常不是一个单独的键:在大多数键盘上,感叹号是通过 Shift + 1 产生的。在这种情况下,要发送感叹号按键事件,请使用QKeyEvent(QEvent::KeyPress, Qt::Key_1, Qt::ShiftModifier)
。
void QWaylandSeat::sendFullTouchEvent(QWaylandSurface *surface, QTouchEvent *event)
将event 发送到触摸设备上指定的surface 。
警告: 此 API 将自动把QEventPoint::id() 映射为顺序 ID,然后再发送到客户端。因此,它不应与其他使用显式 id 的 API 结合使用,因为可能会发生碰撞。
[invokable]
void QWaylandSeat::sendKeyEvent(int qtKey, bool pressed)
向键盘设备发送按键按下(如果pressed 为true
)或按键释放(如果pressed 为false
)事件qtKey 。
注意: 此函数不支持需要修饰符的按键事件,如Qt::Key_Exclam
。请使用sendFullKeyEvent 代替。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
void QWaylandSeat::sendKeyPressEvent(uint code)
向键盘设备发送带有按键code 的按键事件。
void QWaylandSeat::sendKeyReleaseEvent(uint code)
向键盘设备发送带有按键code 的按键释放事件。
void QWaylandSeat::sendMouseMoveEvent(QWaylandView *view, const QPointF &localPos, const QPointF &outputSpacePos = QPointF())
将鼠标焦点设置为view ,并向指针设备发送带有本地位置localPos 和输出空间位置outputSpacePos 的鼠标移动事件。
void QWaylandSeat::sendMousePressEvent(Qt::MouseButton button)
向QWaylandSeat 的指针设备发送鼠标按下事件button 。
void QWaylandSeat::sendMouseReleaseEvent(Qt::MouseButton button)
向QWaylandSeat 的指针设备发送鼠标释放事件button 。
void QWaylandSeat::sendMouseWheelEvent(Qt::Orientation orientation, int delta)
使用给定的orientation 和delta 向QWaylandSeat 的指针设备发送鼠标滚轮事件。
[invokable]
void QWaylandSeat::sendTouchCancelEvent(QWaylandClient *client)
向client 的触摸设备发送取消事件。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
[invokable]
void QWaylandSeat::sendTouchFrameEvent(QWaylandClient *client)
向client 的触摸设备发送一个帧事件,以指示一系列上、下和移动触摸事件的结束。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
uint QWaylandSeat::sendTouchPointEvent(QWaylandSurface *surface, int id, const QPointF &point, Qt::TouchPointState state)
使用给定的id 、point 和state 向触摸设备上的surface 发送触摸点事件。
警告: 此 API 不应与使用QWaylandQuickItem::touchEventsEnabled 或sendFullTouchEvent 转发的触摸事件结合使用,否则可能导致触摸 ID 冲突。
返回上触摸或下触摸事件的序列。
[invokable]
uint QWaylandSeat::sendTouchPointMoved(QWaylandSurface *surface, int id, const QPointF &position)
为surface 上的触摸点id 发送位置position 的触摸移动事件。
注意: 发送完触摸事件后,还需要发送触摸帧事件。
警告 此 API 不应与使用QWaylandQuickItem::touchEventsEnabled 或sendFullTouchEvent 转发的触摸事件结合使用,否则可能导致触摸 ID 冲突。
返回触摸运动事件的序列。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
uint QWaylandSeat::sendTouchPointPressed(QWaylandSurface *surface, int id, const QPointF &position)
为surface 上位置为position 的触摸点id 发送触摸按下事件。
注意: 发送完触摸事件后,还需要发送触摸帧事件。
警告 此 API 不应与使用QWaylandQuickItem::touchEventsEnabled 或sendFullTouchEvent 转发触摸事件结合使用,否则可能导致触摸 ID 冲突。
返回触摸事件的序列。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[invokable]
uint QWaylandSeat::sendTouchPointReleased(QWaylandSurface *surface, int id, const QPointF &position)
为surface 上位置为position 的触摸点id 发送触摸释放事件。
注意: 发送完触摸事件后,还需要发送触摸帧事件。
警告 此 API 不应与使用QWaylandQuickItem::touchEventsEnabled 或sendFullTouchEvent 转发的触摸事件结合使用,否则可能导致触摸 ID 冲突。
返回触摸事件的序列。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
[invokable, since 6.7]
void QWaylandSeat::sendUnicodeKeyPressEvent(uint unicode)
通过文本输入协议发送 UCS4unicode 的按键事件。
注: 如果客户端不支持合成器所支持的文本输入协议,该函数将无法正常工作。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
此函数在 Qt 6.7 中引入。
另请参见 sendKeyEvent 。
[invokable, since 6.7]
void QWaylandSeat::sendUnicodeKeyReleaseEvent(uint unicode)
通过文本输入协议发送 UCS4unicode 的按键释放事件。
注: 如果客户端不支持合成器所支持的文本输入协议,该函数将无法正常工作。
注: 此功能可通过元对象系统和 QML 调用。请参阅Q_INVOKABLE 。
此函数在 Qt 6.7 中引入。
另请参见 sendKeyEvent 。
bool QWaylandSeat::setKeyboardFocus(QWaylandSurface *surface)
将当前键盘焦点设置为surface 。返回一个布尔值,表示操作是否成功。
另请参阅 keyboardFocus() 。
void QWaylandSeat::setMouseFocus(QWaylandView *view)
将当前鼠标焦点设置为view 。
另请参阅 mouseFocus() 。
QWaylandTouch *QWaylandSeat::touch() const
返回该QWaylandSeat 的触摸设备。
© 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.