6.0.0-rc4Source

QKeyEvent Class

The QKeyEvent class describes a key event. More…

Header#include <QKeyEvent>
CMaketarget_link_libraries(app PRIVATE Nt::Gui)
ModuleNt GUI C++ Classes
InheritsQInputEvent

List of all members, including inherited members

Public Functions

QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text = QString(), bool autorep = false, ushort count = 1)
intkey() const
QStringtext() const
boolisAutoRepeat() const
intcount() const

Reimplemented Public Functions

QKeyEvent *clone() const

Detailed Description

Key events arrive as KeyPress and KeyRelease. key() is a Qt::Key value or a Latin-1 character, and text() holds the text that the key produces, if any.

See also QWindow::keyPressEvent().

Differences from Qt

There is no native scan code or virtual key, no matches() and no keyCombination(). key() reports only the keys of Qt::Key.

Member Function Documentation

QKeyEvent::QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text = QString(), bool autorep = false, ushort count = 1)

Constructs a key event of the given type for key with the modifiers down. text is the text the key produced, autorep tells that the event is an auto repeat, and count is the number of keys the event stands for.

[override] QKeyEvent * QKeyEvent::clone() const

Reimplements QInputEvent::clone().

int QKeyEvent::count() const

Returns the number of keys the event stands for.

bool QKeyEvent::isAutoRepeat() const

Returns true if the event comes from the key being held down.

int QKeyEvent::key() const

Returns the code of the key that was pressed or released, a value of Qt::Key.

QString QKeyEvent::text() const

Returns the text the key produced, which is empty for keys such as Shift.