Reputation: 1590
I know how to post single key event
QKeyEvent *poKeyEvent = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
QCoreApplication::postEvent (this, poKeyEvent);
Now I want to post a combination of key events
for example QKeySequence(tr("Ctrl+L"));
Is this a proper way of posting a key sequence events?
// First key event - 'Ctrl'
QKeyEvent *poFirstKeyEvent = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Control, Qt::NoModifier);
QCoreApplication::postEvent (this, poFirstKeyEvent);
// Second key event - 'L'
QKeyEvent *poSecondtKeyEvent = new QKeyEvent ( QEvent::KeyPress, Qt::Key_L, Qt::NoModifier);
QCoreApplication::postEvent (this, poSecondtKeyEvent);
Any other way to implement this?
Thanks,
Upvotes: 2
Views: 806