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. Context menu when right-clicking on a QMenu on Linux

Context menu when right-clicking on a QMenu on Linux

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 63 Views
  • 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.
  • S Offline
    S Offline
    stefano.cr
    wrote 5 days ago last edited by
    #1

    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 to Qt::CustomContextMenu and right clicking on an action inside it caused the menu to emit the customContextMenuRequested 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();
    }
    
    1 Reply Last reply
    0
    • C Offline
      C Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote 5 days ago last edited by
      #2

      I would say - https://bugreports.qt.io/browse/QTBUG-134791

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • S Offline
        S Offline
        stefano.cr
        wrote 5 days ago last edited by
        #3

        Thanks. I think you're right: it looks like the same bug I'm experiencing.

        1 Reply Last reply
        0
        • S stefano.cr has marked this topic as solved 5 days ago

        1/3

        11 May 2025, 12:35

        • Login

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