| 头: | #include <QKeyEvent> |
| 继承: | QInputEvent |
| QKeyEvent (Type type , int key , Qt::KeyboardModifiers modifiers , const QString & text = QString(), bool autorep = false, ushort count = 1) | |
| int | count () const |
| bool | isAutoRepeat () const |
| int | key () const |
| bool | matches (QKeySequence::StandardKey key ) const |
| Qt::KeyboardModifiers | modifiers () const |
| quint32 | nativeModifiers () const |
| quint32 | nativeScanCode () const |
| quint32 | nativeVirtualKey () const |
| QString | text () const |
| bool | operator== (QKeyEvent * e , QKeySequence::StandardKey key ) |
| bool | operator== (QKeySequence::StandardKey key , QKeyEvent * e ) |
The QKeyEvent 类描述键事件。
键事件会被发送给具有键盘输入聚焦的 Widget,当按下 (或释放) 按键时。
A key event contains a special accept flag that indicates whether the receiver will handle the key event. You should call ignore () if the key press or release event is not handled by your widget. A key event is propagated up the parent widget chain until a widget accepts it with accept () or an event filter consumes it. Key events for multimedia keys are ignored by default. You should call accept () if your widget handles those events.
The QWidget::setEnable() function can be used to enable or disable mouse and keyboard events for a widget.
事件处理程序 QWidget::keyPressEvent (), QWidget::keyReleaseEvent (), QGraphicsItem::keyPressEvent () 和 QGraphicsItem::keyReleaseEvent () 接收键事件。
另请参阅 QFocusEvent and QWidget::grabKeyboard ().
构造键事件对象。
The type 参数必须是 QEvent::KeyPress , QEvent::KeyRelease ,或 QEvent::ShortcutOverride .
Int key 是代码对于 Qt::Key 是事件循环应监听的。若 key 为 0,事件不是已知按键的结果;例如,它可能是合成序列 (或键盘宏) 的结果。 modifiers 保持键盘修饰符,和给定 text 是按键生成 Unicode 文本。若 autorep 为 True, isAutoRepeat () 将为 true。 count 是事件涉及的按键数。
返回此事件涉及的按键数。若 text () 不为空,这就是字符串的长度。
另请参阅 Qt::WA_KeyCompression .
Returns true if this event comes from an auto-repeating key; returns false if it comes from an initial key press.
注意,若事件是部分由于自动重复导致的多键压缩事件,此函数返回 true 或 false 不确定。
返回按下 (或释放) 的键码。
见 Qt::Key 了解键盘代码的列表。这些代码独立于底层窗口系统。注意,此函数不区分大写和非大写字母,使用 text () 函数 (返回键生成的 Unicode 文本) 为此目的。
值为 0 或 Qt::Key_unknown 意味着事件不是已知按键的结果;例如,它可能是合成序列、键盘宏、或由于键事件压缩的结果。
另请参阅 Qt::WA_KeyCompression .
Returns true if the key event matches the given standard key ;否则返回 false。
该函数在 Qt 4.2 引入。
返回事件发生后立即存在的键盘修饰符标志。
警告: 无法始终信任此函数。用户可能混淆,通过按下两 Shift 键 (同时) 然后释放其中之一,例如。
另请参阅 QApplication::keyboardModifiers ().
返回键事件的本机修饰符。若键事件不包含此数据,返回 0。
注意:本机修饰符可能为 0,即使键事件包含扩展信息。
该函数在 Qt 4.2 引入。
返回键事件的本机扫描代码。若键事件不包含此数据,返回 0。
注意:本机扫描代码可能为 0,即使键事件包含扩展信息。
注意:在 Mac OS/X,此函数没什么用,因为没有办法从 Carbon 或 Cocoa 获得扫描码。函数始终返回 1 (或 0 当解释上文情况时)。
该函数在 Qt 4.2 引入。
返回本机虚拟键,或键事件的键符号。若键事件不包含此数据,返回 0。
注意:本机虚拟键可能为 0, 即使键事件包含扩展信息。
该函数在 Qt 4.2 引入。
Returns the Unicode text that this key generated. The text returned can be an empty string in cases where modifier keys, such as Shift, Control, Alt, and Meta, are being pressed or released. In such cases key () will contain a valid value.
另请参阅 Qt::WA_KeyCompression .
返回 true 若 key is currently bound to the key combination specified by e .
相当于
e->matches(key)
.
返回 true 若 key is currently bound to the key combination specified by e .
相当于
e->matches(key)
.