Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Open and navigate menu from a callback programatically
Forum Updated to NodeBB v4.3 + New Features

Open and navigate menu from a callback programatically

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 211 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    patmicom
    wrote on last edited by
    #1

    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;
    }

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved