Important: Please read the Qt Code of Conduct -

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

    //Try #2

    //Try #3
    QKeyEvent altPress(QEvent::KeyPress, Qt::Key_Alt, Qt::NoModifier);
    QKeyEvent altRelease(QEvent::KeyRelease, Qt::Key_Alt, Qt::NoModifier);


    cout<<"Open clicked"<<endl;

  • Lifetime Qt Champion


    Did you consider using the QtGamepad module ? It might provide what you need.

Log in to reply