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:

Qt Code:
  1. QKeyEvent keyEvent(QEvent::KeyPress,Qt::Key_Tab, Qt::NoModifier);
  2. QWidget* pWidget = qApp->activeWindow()->focusWidget();
  3. qApp->sendEvent(pWidget, &keyEvent);
To copy to clipboard, switch view to plain text mode 

… for tab input or:

Qt Code:
  1. QKeyEvent keyEvent(QEvent::KeyPress,Qt::Key_..., Qt::NoModifier);
  2. QWidget* pWidget = qApp->activePopupWidget();
  3. 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?