Unsolved Open and navigate menu from a callback programatically
-
I want to navigate a menu with an xbox360 controller. I can navigate the menu with the controller simulating a mouse motion and mouse clicks but it's awkward. Instead I would like to push a controller button and highlight an option in the main menu and use the controller keys to emulate the keyboard arrow keys and return key. The first thing that has to happen is to highlight a menu option on a callback. For experimentation I am using a qt pushbutton to attempt to open the menu and highlight an option. So far no success, any suggestions? I have tried the following:
void mainWindow::on_action1B_triggered(bool checked)
{
cout<<"Menu Option 1B Selected"<<endl;
}void mainWindow::on_pushButton_openmenu_clicked()
{
//Try #1
ui->menuBar->setFocus(Qt::OtherFocusReason);//Try #2
ui->menuBar->setActiveAction(ui->action1B);//Try #3
QKeyEvent altPress(QEvent::KeyPress, Qt::Key_Alt, Qt::NoModifier);
QKeyEvent altRelease(QEvent::KeyRelease, Qt::Key_Alt, Qt::NoModifier);qApp->sendEvent(ui->menuBar,&altPress);
qApp->sendEvent(ui->menuBar,&altRelease);cout<<"Open clicked"<<endl;
} -
Hi,
Did you consider using the QtGamepad module ? It might provide what you need.