[][src]Struct qt_gui::QKeyEvent

#[repr(C)]pub struct QKeyEvent { /* fields omitted */ }

The QKeyEvent class describes a key event.

C++ class: QKeyEvent.

C++ documentation:

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 QEvent::KeyPress and QEvent::KeyRelease, so there is no need to call accept() when acting on a key event. For QEvent::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 QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.

The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(), QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent() receive key events.

Methods

impl QKeyEvent[src]

pub unsafe fn copy_from(
    &self,
    other: impl CastInto<Ref<QKeyEvent>>
) -> Ref<QKeyEvent>
[src]

The QKeyEvent class describes a key event.

Calls C++ function: QKeyEvent& QKeyEvent::operator=(const QKeyEvent& other).

C++ documentation:

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 QEvent::KeyPress and QEvent::KeyRelease, so there is no need to call accept() when acting on a key event. For QEvent::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 QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.

The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(), QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent() receive key events.

pub unsafe fn count(&self) -> c_int[src]

Returns the number of keys involved in this event. If text() is not empty, this is simply the length of the string.

Calls C++ function: int QKeyEvent::count() const.

C++ documentation:

Returns the number of keys involved in this event. If text() is not empty, this is simply the length of the string.

See also Qt::WA_KeyCompression.

pub unsafe fn is_auto_repeat(&self) -> bool[src]

Returns true if this event comes from an auto-repeating key; returns false if it comes from an initial key press.

Calls C++ function: bool QKeyEvent::isAutoRepeat() const.

C++ documentation:

Returns true if this event comes from an auto-repeating key; returns false if it comes from an initial key press.

Note that if the event is a multiple-key compressed event that is partly due to auto-repeat, this function could return either true or false indeterminately.

pub unsafe fn key(&self) -> c_int[src]

Returns the code of the key that was pressed or released.

Calls C++ function: int QKeyEvent::key() const.

C++ documentation:

Returns the code of the key that was pressed or released.

See Qt::Key for the list of keyboard codes. These codes are independent of the underlying window system. Note that this function does not distinguish between capital and non-capital letters, use the text() function (returning the Unicode text the key generated) for this purpose.

A value of either 0 or Qt::Key_unknown means that the event is not the result of a known key; for example, it may be the result of a compose sequence, a keyboard macro, or due to key event compression.

See also Qt::WA_KeyCompression.

pub unsafe fn matches(&self, key: StandardKey) -> bool[src]

Returns true if the key event matches the given standard key; otherwise returns false.

Calls C++ function: bool QKeyEvent::matches(QKeySequence::StandardKey key) const.

C++ documentation:

Returns true if the key event matches the given standard key; otherwise returns false.

This function was introduced in Qt 4.2.

pub unsafe fn modifiers(&self) -> QFlags<KeyboardModifier>[src]

Returns the keyboard modifier flags that existed immediately after the event occurred.

Calls C++ function: QFlags<Qt::KeyboardModifier> QKeyEvent::modifiers() const.

C++ documentation:

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 QGuiApplication::keyboardModifiers().

pub unsafe fn native_modifiers(&self) -> u32[src]

Returns the native modifiers of a key event. If the key event does not contain this data 0 is returned.

Calls C++ function: quint32 QKeyEvent::nativeModifiers() const.

C++ documentation:

Returns the native modifiers of a key event. If the key event does not contain this data 0 is returned.

Note: The native modifiers may be 0, even if the key event contains extended information.

This function was introduced in Qt 4.2.

pub unsafe fn native_scan_code(&self) -> u32[src]

Returns the native scan code of the key event. If the key event does not contain this data 0 is returned.

Calls C++ function: quint32 QKeyEvent::nativeScanCode() const.

C++ documentation:

Returns the native scan code of the key event. If the key event does not contain this data 0 is returned.

Note: The native scan code may be 0, even if the key event contains extended information.

Note: On Mac OS/X, this function is not useful, because there is no way to get the scan code from Carbon or Cocoa. The function always returns 1 (or 0 in the case explained above).

This function was introduced in Qt 4.2.

pub unsafe fn native_virtual_key(&self) -> u32[src]

Returns the native virtual key, or key sym of the key event. If the key event does not contain this data 0 is returned.

Calls C++ function: quint32 QKeyEvent::nativeVirtualKey() const.

C++ documentation:

Returns the native virtual key, or key sym of the key event. If the key event does not contain this data 0 is returned.

Note: The native virtual key may be 0, even if the key event contains extended information.

This function was introduced in Qt 4.2.

pub unsafe fn from_type_int_q_flags_keyboard_modifier_q_string_bool_ushort(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>,
    text: impl CastInto<Ref<QString>>,
    autorep: bool,
    count: c_ushort
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers, const QString& text = …, bool autorep = …, unsigned short count = …).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

pub unsafe fn from_type_int_q_flags_keyboard_modifier3_u32_q_string_bool_ushort(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>,
    native_scan_code: u32,
    native_virtual_key: u32,
    native_modifiers: u32,
    text: impl CastInto<Ref<QString>>,
    autorep: bool,
    count: c_ushort
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString& text = …, bool autorep = …, unsigned short count = …).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

In addition to the normal key event data, also contains nativeScanCode, nativeVirtualKey and nativeModifiers. This extra data is used by the shortcut system, to determine which shortcuts to trigger.

pub unsafe fn from_type_int_q_flags_keyboard_modifier_q_string_bool(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>,
    text: impl CastInto<Ref<QString>>,
    autorep: bool
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers, const QString& text = …, bool autorep = …).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

pub unsafe fn from_type_int_q_flags_keyboard_modifier_q_string(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>,
    text: impl CastInto<Ref<QString>>
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers, const QString& text = …).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

pub unsafe fn from_type_int_q_flags_keyboard_modifier(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

pub unsafe fn from_type_int_q_flags_keyboard_modifier3_u32_q_string_bool(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>,
    native_scan_code: u32,
    native_virtual_key: u32,
    native_modifiers: u32,
    text: impl CastInto<Ref<QString>>,
    autorep: bool
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString& text = …, bool autorep = …).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

In addition to the normal key event data, also contains nativeScanCode, nativeVirtualKey and nativeModifiers. This extra data is used by the shortcut system, to determine which shortcuts to trigger.

pub unsafe fn from_type_int_q_flags_keyboard_modifier3_u32_q_string(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>,
    native_scan_code: u32,
    native_virtual_key: u32,
    native_modifiers: u32,
    text: impl CastInto<Ref<QString>>
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers, const QString& text = …).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

In addition to the normal key event data, also contains nativeScanCode, nativeVirtualKey and nativeModifiers. This extra data is used by the shortcut system, to determine which shortcuts to trigger.

pub unsafe fn from_type_int_q_flags_keyboard_modifier3_u32(
    type_: Type,
    key: c_int,
    modifiers: QFlags<KeyboardModifier>,
    native_scan_code: u32,
    native_virtual_key: u32,
    native_modifiers: u32
) -> CppBox<QKeyEvent>
[src]

Constructs a key event object.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(QEvent::Type type, int key, QFlags<Qt::KeyboardModifier> modifiers, quint32 nativeScanCode, quint32 nativeVirtualKey, quint32 nativeModifiers).

C++ documentation:

Constructs a key event object.

The type parameter must be QEvent::KeyPress, QEvent::KeyRelease, or QEvent::ShortcutOverride.

Int key is the code for the Qt::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.

In addition to the normal key event data, also contains nativeScanCode, nativeVirtualKey and nativeModifiers. This extra data is used by the shortcut system, to determine which shortcuts to trigger.

pub unsafe fn new_copy(
    other: impl CastInto<Ref<QKeyEvent>>
) -> CppBox<QKeyEvent>
[src]

The QKeyEvent class describes a key event.

Calls C++ function: [constructor] void QKeyEvent::QKeyEvent(const QKeyEvent& other).

C++ documentation:

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 QEvent::KeyPress and QEvent::KeyRelease, so there is no need to call accept() when acting on a key event. For QEvent::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 QWidget::setEnabled() function can be used to enable or disable mouse and keyboard events for a widget.

The event handlers QWidget::keyPressEvent(), QWidget::keyReleaseEvent(), QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent() receive key events.

pub unsafe fn text(&self) -> CppBox<QString>[src]

Returns the Unicode text that this key generated.

Calls C++ function: QString QKeyEvent::text() const.

C++ documentation:

Returns the Unicode text that this key generated.

Return values when modifier keys such as Shift, Control, Alt, and Meta are pressed differ among platforms and could return an empty string.

Note: key() will always return a valid value, independent of modifier keys.

See also Qt::WA_KeyCompression.

Methods from Deref<Target = QInputEvent>

pub unsafe fn copy_from(
    &self,
    other: impl CastInto<Ref<QInputEvent>>
) -> Ref<QInputEvent>
[src]

The QInputEvent class is the base class for events that describe user input.

Calls C++ function: QInputEvent& QInputEvent::operator=(const QInputEvent& other).

C++ documentation:

The QInputEvent class is the base class for events that describe user input.

pub unsafe fn modifiers(&self) -> QFlags<KeyboardModifier>[src]

Returns the keyboard modifier flags that existed immediately before the event occurred.

Calls C++ function: QFlags<Qt::KeyboardModifier> QInputEvent::modifiers() const.

C++ documentation:

Returns the keyboard modifier flags that existed immediately before the event occurred.

See also QGuiApplication::keyboardModifiers().

pub unsafe fn set_modifiers(&self, amodifiers: QFlags<KeyboardModifier>)[src]

Calls C++ function: void QInputEvent::setModifiers(QFlags<Qt::KeyboardModifier> amodifiers).

pub unsafe fn set_timestamp(&self, atimestamp: c_ulong)[src]

Calls C++ function: void QInputEvent::setTimestamp(unsigned long atimestamp).

pub unsafe fn timestamp(&self) -> c_ulong[src]

Returns the window system's timestamp for this event. It will normally be in milliseconds since some arbitrary point in time, such as the time when the system was started.

Calls C++ function: unsigned long QInputEvent::timestamp() const.

C++ documentation:

Returns the window system's timestamp for this event. It will normally be in milliseconds since some arbitrary point in time, such as the time when the system was started.

Trait Implementations

impl CppDeletable for QKeyEvent[src]

unsafe fn delete(&self)[src]

Calls C++ function: virtual [destructor] void QKeyEvent::~QKeyEvent().

impl Deref for QKeyEvent[src]

type Target = QInputEvent

The resulting type after dereferencing.

fn deref(&self) -> &QInputEvent[src]

Calls C++ function: QInputEvent* static_cast<QInputEvent*>(QKeyEvent* ptr).

impl DynamicCast<QKeyEvent> for QInputEvent[src]

unsafe fn dynamic_cast(ptr: Ptr<QInputEvent>) -> Ptr<QKeyEvent>[src]

Calls C++ function: QKeyEvent* dynamic_cast<QKeyEvent*>(QInputEvent* ptr).

impl DynamicCast<QKeyEvent> for QEvent[src]

unsafe fn dynamic_cast(ptr: Ptr<QEvent>) -> Ptr<QKeyEvent>[src]

Calls C++ function: QKeyEvent* dynamic_cast<QKeyEvent*>(QEvent* ptr).

impl PartialEq<StandardKey> for QKeyEvent[src]

fn eq(&self, key: &StandardKey) -> bool[src]

Returns true if page layout lhs is equal to page layout rhs, i.e. if all the attributes are exactly equal.

Calls C++ function: bool operator==(QKeyEvent* e, QKeySequence::StandardKey key).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for bool operator==(const QPageLayout &lhs, const QPageLayout &rhs):

Returns true if page layout lhs is equal to page layout rhs, i.e. if all the attributes are exactly equal.

Note that this is a strict equality, especially for page size where the QPageSize ID, name and size must exactly match, and the margins where the units must match.

See also QPageLayout::isEquivalentTo().

impl StaticDowncast<QKeyEvent> for QInputEvent[src]

unsafe fn static_downcast(ptr: Ptr<QInputEvent>) -> Ptr<QKeyEvent>[src]

Calls C++ function: QKeyEvent* static_cast<QKeyEvent*>(QInputEvent* ptr).

impl StaticDowncast<QKeyEvent> for QEvent[src]

unsafe fn static_downcast(ptr: Ptr<QEvent>) -> Ptr<QKeyEvent>[src]

Calls C++ function: QKeyEvent* static_cast<QKeyEvent*>(QEvent* ptr).

impl StaticUpcast<QEvent> for QKeyEvent[src]

unsafe fn static_upcast(ptr: Ptr<QKeyEvent>) -> Ptr<QEvent>[src]

Calls C++ function: QEvent* static_cast<QEvent*>(QKeyEvent* ptr).

impl StaticUpcast<QInputEvent> for QKeyEvent[src]

unsafe fn static_upcast(ptr: Ptr<QKeyEvent>) -> Ptr<QInputEvent>[src]

Calls C++ function: QInputEvent* static_cast<QInputEvent*>(QKeyEvent* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.