Details
-
Suggestion
-
Resolution: Done
-
P2: Important
-
None
-
5.13.1
-
-
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(); }