Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-136595

[Regression since 6.2.2] Under Android, can only select menu item by "tap and hold"

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P1: Critical
    • None
    • 6.9.0
    • GUI: Menus
    • None
    • Android

    Description

      When deploying a simple Qt app under Android, I experience unexpected behaviour when trying to select menu items.

      To workaround https://bugreports.qt.io/browse/QTBUG-52005, I set Qt::AA_DontUseNativeMenuBar. 

      Then, you can't tap/release screen to show menu and later tap/release screen to trigger a menu item (as you can, under Windows, click to show menu and later click to select a menu item). To trigger a menu item, you must now tap screen and hold finder on screen to show the menu, move the finger without releasing the screen to go to the item you want to trigger and then release screen.

      This way to select a menu item is not intuitive...when using non-Qt apps like Chrome for instance, you tap screen to show menu, and you later tap again to select a menu item. Qt apps should behave the same way.

      This issue is new in 6.9.0, 6.2.2 works fine.

      Qt 6.2.2 without Qt::AA_DontUseNativeMenuBar, you can show and later select menu item.
      Qt 6.2.2 with Qt::AA_DontUseNativeMenuBar, you can show and later select menu item.
      Qt 6.2.2 without Qt::AA_DontUseNativeMenuBar, you can show and later select menu item (but QMenuBar are not shown).
      Qt 6.2.2 with Qt::AA_DontUseNativeMenuBar, you cannot show and later select menu item.

      Sample program to reproduce issue:

      main.cpp:

      #include <QApplication>
      #include "mainframe.h"
      int main( int argc, char* argv[] )
      {
          // https://bugreports.qt.io/browse/QTBUG-52005 (menuBor not visible)
          // workaround to see QMainWindow's menubar
          QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
          QApplication app(argc, argv);
          MainFrame wnd;
          wnd.show();
          return app.exec();
      }
      

      mainframe.h:

      #include <QMainWindow>
      class MainFrame : public QMainWindow
      {
          Q_OBJECT
      public:
          MainFrame();
      public slots:
          void actionExecuted();
      private:
          QMenu* m_menu;
      };
      

      mainframe.cpp:

      #include "mainframe.h"
      #include <QPushButton>
      #include <QMenu>
      #include <QMenuBar>
      #include <QMessageBox>
      
      MainFrame::MainFrame()
      {
          QMenuBar* myMenuBar = new QMenuBar( this );
          setMenuBar( myMenuBar );
          QAction* action1 = myMenuBar->addMenu( "File" )->addAction( "From menu" );
          QObject::connect(action1, SIGNAL(triggered()), this, SLOT(actionExecuted()));
          QPushButton* button = new QPushButton("Show menu", this); 
          setCentralWidget(button);
          m_menu = new QMenu(button); QAction* action2 = m_menu->addAction("From button");
          button->setMenu(m_menu);
          QObject::connect(action2, SIGNAL(triggered()), this, SLOT(actionExecuted()));
      }
      
      void MainFrame::actionExecuted()
      {
          QMessageBox::information(this, "OK", "Action executed", QMessageBox::Ok);
      }

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            jpo38 Jean Porcherot
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes