Context menu when right-clicking on a QMenu on Linux
-
wrote 5 days ago last edited by
Does anyone know whether something has changed from Qt 6.7 to 6.8 in how a
QMenu
handles a right click? In Qt 6.7, setting the menu's context menu policy toQt::CustomContextMenu
and right clicking on an action inside it caused the menu to emit thecustomContextMenuRequested
signal, while in Qt 6.8 this doesn't seem to work anymore and right-clicking on an action triggers the action.I'm asking this because I'm the maintainer of the Konqueror web browser and I noticed that some of the functionality of its bookmarks menu has disappeared a few months ago. When the user right-clicked on a bookmark in the bookmarks menu, Konqueror used to display a popup menu with actions associated with the bookmark (open it in a new tab, editing its properties, ...), but now it just triggers the action by opening the bookmark URL.
Using virtual machines with older Qt versions, I found out that Konqueror bookmarks menu correctly displayed the popup menu with Qt 6.7.2, but stopped doing so with Qt 6.8.0, so I guess the change came with Qt 6.8.0. However, searching the web for related changes in Qt between these versions didn't produce any result. The Konqueror code handling the bookmarks menu hasn't been changed recently, so I don't think the problem is in Konqueror itself. Initially I thought it could be a change in the KDE Frameworks that Konqueror uses, but I don't think this is the case as the simple Qt-only program below also shows this behavior: in Qt 6.7, when right clicking on the "Test" action you can see the "CONTEXT MENU REQUESTED AT" output, while with Qt 6.8, you get the "ACTION TRIGGERED" output.
Thanks in advance
#include <QMainWindow> #include <QApplication> #include <Qt> #include <QDebug> #include <QMenu> #include <QAction> #include <QMenuBar> int main(int argc, char **argv) { QApplication app(argc, argv); QMainWindow mw; QMenu *m = mw.menuBar()->addMenu("Menu"); m->setContextMenuPolicy(Qt::CustomContextMenu); QObject::connect(m, &QWidget::customContextMenuRequested, &mw, [](const QPoint &pt){qDebug() << "CONTEXT MENU REQUESTED AT" << pt;}); QAction *a = m->addAction("Test"); QObject::connect(a, &QAction::triggered, &mw, [](bool){qDebug() << "ACTION TRIGGERED";}); mw.show(); return app.exec(); }
-
I would say - https://bugreports.qt.io/browse/QTBUG-134791
-
wrote 5 days ago last edited by
Thanks. I think you're right: it looks like the same bug I'm experiencing.
-
1/3