本页内容

KeyEvent QML Type

QKeyEvent C++ 类的 QML 前端。更多内容...

Import Statement: import Qt3D.Input 2.12
In C++: QKeyEvent
Status: Deprecated

此类型已弃用。我们强烈建议不要在新代码中使用它。

属性

方法

详细说明

无法直接创建 KeyEvent QML 类型。该类型的对象用作KeyboardHandler 中的信号参数。

属性文档

accepted : bool

将accepted属性设置为true 可防止键事件传播到该项的父项。

通常,如果该项目对键事件进行了处理,则应将其设置为“accepted”,以防止其父级项目也对同一事件做出响应。

count : int [read-only]

存储该事件涉及的键的数量。如果text 不为空,则此处仅表示该字符串的长度。

isAutoRepeat : bool [read-only]

表示该事件是否来自自动重复键。

key : int [read-only]

该属性存储了被按下或松开的键的代码。

有关键盘代码列表,请参阅Qt.Key 。

另请参阅 KeyEvent.key 。

modifiers : int [read-only]

该属性保存了事件发生前瞬间存在的键盘修饰符标志。

另请参阅 KeyEvent.modifiers 。

nativeScanCode : quint32 [read-only]

该属性包含被按下的键的原生扫描码。该值由QKeyEvent 直接传递过来,未作任何修改。

另请参阅 QKeyEvent::nativeScanCode()。

text : string [read-only]

该属性存储由该键生成的 Unicode 文本。当按下或松开修饰键(如 Shift、Control、Alt 和 Meta)时,返回的文本可能是空字符串。在这种情况下,key 将包含一个有效值。

方法文档

bool matches(StandardKey key)

如果键事件符合给定的标准key ,则返回true ;否则返回false 。

另请参阅 QKeySequence::StandardKey 。

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