| 頭: | #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)
.