QKeyEvent露
- PyQt5.QtGui.QKeyEvent
Inherits from QInputEvent.
Description露
The QKeyEvent class describes a key event.
Key events are sent to the widget with keyboard input focus when keys are pressed or released.
A key event contains a special accept flag that indicates whether the receiver will handle the key event. This flag is set by default for KeyPress and KeyRelease, so there is no need to call accept() when acting on a key event. For ShortcutOverride the receiver needs to explicitly accept the event to trigger the override. Calling ignore() on a key event will propagate it to the parent widget. The event is propagated up the parent widget chain until a widget accepts it or an event filter consumes it.
The setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.
The event handlers keyPressEvent(), keyReleaseEvent(), QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent() receive key events.
See also
Methods露
- __init__(QKeyEvent)
TODO
- __init__(Type, int, Union[KeyboardModifiers, KeyboardModifier], text: str = '', autorep: bool = False, count: int = 1)
Constructs a key event object.
The type parameter must be KeyPress, KeyRelease, or ShortcutOverride.
Int key is the code for the Key that the event loop should listen for. If key is 0, the event is not a result of a known key; for example, it may be the result of a compose sequence or keyboard macro. The modifiers holds the keyboard modifiers, and the given text is the Unicode text that the key generated. If autorep is true, isAutoRepeat() will be true. count is the number of keys involved in the event.
- __init__(Type, int, Union[KeyboardModifiers, KeyboardModifier], int, int, int, text: str = '', autorep: bool = False, count: int = 1)
TODO
- count() → int
TODO
- __eq__(StandardKey) → bool
TODO
- isAutoRepeat() → bool
TODO
- key() → int
TODO
- __len__() → int
TODO
- matches(StandardKey) → bool
TODO
- modifiers() → KeyboardModifiers
Returns the keyboard modifier flags that existed immediately after the event occurred.
Warning: This function cannot always be trusted. The user can confuse it by pressing both Shift keys simultaneously and releasing one of them, for example.
See also
- nativeModifiers() → int
TODO
- nativeScanCode() → int
TODO
- nativeVirtualKey() → int
TODO
- __ne__(StandardKey) → bool
TODO
- text() → str
TODO