How to use QKeyEvents in Qt
Jump to navigation
Jump to search
Overview[edit | edit source]
Classes used in this code: QKeyEvents-Describes a key event.
Event Code[edit | edit source]
void my_app::clicked0 () //For tab Event
{
QKeyEvent key(QKeyEvent::KeyPress, Qt::Key_Tab, Qt::NoModifier, "Tab", false, 0 );
QApplication::sendEvent(this, &key);
}
void my_app::clicked1 () //For tab shift
{
QKeyEvent key(QKeyEvent::KeyPress, Qt::Key_Tab, Qt::ShiftModifier, "Tab-Shift", false, 0 );
QApplication::sendEvent(this, &key);
}
void my_app::clicked2 () //For space
{
QKeyEvent key(QKeyEvent::KeyPress, Qt::Key_Return, Qt::NoModifier, "Return", false, 0 );
QApplication::sendEvent(this, &key);
}
void my_app::clicked3 () //For enter Event
{
QKeyEvent key(QKeyEvent::KeyPress, Qt::Key_Space, Qt::NoModifier, "Space", false, 0 );
QApplication::sendEvent(this, &key);
}