Hi,
I'm working on a piece of software (on Linux/X11), which uses Qt application menus with simulated keyboard inputs and no mouse.
Simulating keyboard inputs works with:
QWidget* pWidget
= qApp
->activeWindow
()->focusWidget
();
qApp->sendEvent(pWidget, &keyEvent);
QKeyEvent keyEvent(QEvent::KeyPress,Qt::Key_Tab, Qt::NoModifier);
QWidget* pWidget = qApp->activeWindow()->focusWidget();
qApp->sendEvent(pWidget, &keyEvent);
To copy to clipboard, switch view to plain text mode
… for tab input or:
QWidget* pWidget
= qApp
->activePopupWidget
();
qApp->sendEvent(pWidget, &keyEvent);
QKeyEvent keyEvent(QEvent::KeyPress,Qt::Key_..., Qt::NoModifier);
QWidget* pWidget = qApp->activePopupWidget();
qApp->sendEvent(pWidget, &keyEvent);
To copy to clipboard, switch view to plain text mode
… for other keys
But I always have to use the mouse to get an initial highlighted menu item. I tried a lot of things to get this highlighted item by program input.
With Qmenu::exec() I succeded to open a popup menu but could not get a highlighted item there, so the simulated inputs have no effect.
What am I doing wrong?
Bookmarks