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

MenuBar does not open a menu immediately on mouse press and does not support press-hold-release

    XMLWordPrintable

Details

    • Linux/X11
    • 62965b67a (dev), 78c6fb4cb (6.5)

    Description

      A menu using MenuBar opens only once the mouse is clicked and released on the menu item. This can feel a bit sluggish, especially if the menu takes a bit of time to show up as it tends to the first time it is opened. It would be better if a menu opened as soon as the mouse is pressed. This is how menus in almost all desktop applications behave.

      MenuBar also does not support press-hold-release usage, which is common in many  applications/toolkits, and is almost universal on Linux. This means that menus can be used like this:

      • Press and hold the mouse button while the pointer is one of the menu bar items. The menu appears immediately.
      • Navigate to the desired menu item and release the button. The item is activated and the menu disappears.

      QML example:

      import QtQuick
      import QtQuick.Controls
      
      ApplicationWindow {
          id: window
          width: 640
          height: 480
          visible: true
      
          menuBar: MenuBar {
              Menu {
                  title: "&File"
      
                  MenuItem {
                      text: "New"
                  }
                  MenuItem {
                      text: "Open"
                  }
                  MenuItem {
                      text: "Save"
                  }
              }
          }
      }
      

      Widgets example:

      
      #include <QtWidgets>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QMainWindow mainWindow;
      
          QWidget *centralWidget = new QWidget;
      
          QMenu *menu = new QMenu("&File", centralWidget);
          menu->addAction("New");
          menu->addAction("Open");
          menu->addAction("Save");
          mainWindow.menuBar()->addMenu(menu);
      
          mainWindow.setCentralWidget(centralWidget);
      
          mainWindow.resize(400, 400);
          mainWindow.show();
      
          return app.exec();
      }
      

      Attachments

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

        Activity

          People

            mitch_curtis Mitch Curtis
            abizjak Ambrož Bizjak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes