QKeyEvent Class
The QKeyEvent class describes a key event. More…
| Header | #include <QKeyEvent> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Gui) |
| Module | Nt GUI C++ Classes |
| Inherits | QInputEvent |
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) | |
| int | key() const |
| QString | text() const |
| bool | isAutoRepeat() const |
| int | count() 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.
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.