Qt3DInput::QKeyEvent Class

class Qt3DInput::QKeyEvent

由 KeyBoardHandler 发送的 QKeyEvent 事件类型。更多

Header: #include <QKeyEvent>
CMake: find_package(Qt6 REQUIRED COMPONENTS 3dinput)
target_link_libraries(mytarget PRIVATE Qt6::3dinput)
qmake: QT += 3dinput
在 QML 中: KeyEvent
继承: QObject
状态:已废弃

属性

公共职能

int count() const
bool isAccepted() const
bool isAutoRepeat() const
int key() const
bool matches(QKeySequence::StandardKey key_) const
int modifiers() const
quint32 nativeScanCode() const
void setAccepted(bool accepted)
QString text() const
QEvent::Type type() const

详细说明

属性文档

accepted : bool

accepted设置为true 可以防止键事件传播到项的父项。

一般来说,如果项目对按键事件做出反应,则应接受该事件,以免父项目也对同一事件做出反应。

访问功能:

bool isAccepted() const
void setAccepted(bool accepted)

[read-only] count : const int

表示该事件涉及的键的个数。如果text 不为空,则为字符串的长度。

访问功能:

int count() const

[read-only] isAutoRepeat : const bool

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

访问功能:

bool isAutoRepeat() const

[read-only] key : const int

该属性包含按下或松开的键的代码。

键盘代码列表请参见Qt.Key

另请参见 QKeyEvent::key()。

访问功能:

int key() const

[read-only] modifiers : const int

该属性保存事件发生前的键盘修改器标记。

另请参阅 QKeyEvent::modifiers().

访问功能:

int modifiers() const

[read-only] nativeScanCode : const quint32

该属性包含按下的按键的本地扫描代码。它将原封不动地从QKeyEvent 传递过来。

访问功能:

quint32 nativeScanCode() const

[read-only] text : const QString

该属性包含按键生成的 Unicode 文本。在按下或释放 Shift、Control、Alt 和 Meta 等修改键时,返回的文本可能是空字符串。在这种情况下,key 将包含一个有效值。

访问函数:

QString text() const

成员函数文档

[invokable] bool QKeyEvent::matches(QKeySequence::StandardKey key_) const

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

注: 可通过元对象系统和 QML 调用该函数。参见Q_INVOKABLE

另请参阅 QKeySequence::StandardKey

QEvent::Type QKeyEvent::type() const

返回事件类型。

相关非会员

QKeyEventPtr

QKeyEvent 的共享指针。

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