Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Could not hover on QMenu in a modal dialog

    General and Desktop
    3
    5
    128
    Loading More Posts
    • 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.
    • Sivan
      Sivan last edited by Sivan

      Hi all,

      I have just recently upgraded to Qt-5.15.2 from Qt-5.4.1 and noticed that I could not hover on a menu which is executed from a modal dialog.
      Here is my example code:

      class MyDialog : public QDialog
      {
      public:
          explicit MyDialog(QWidget* parent = nullptr) : QDialog(parent)
          {
              setMinimumSize(300, 300);
          }
      
          virtual ~MyDialog()
          {
          }
      
      protected:
          virtual void mousePressEvent(QMouseEvent* event) override
          {
              QDialog::mousePressEvent(event);
      
              if (event->button() == Qt::RightButton)
              {
                  QMenu menu;
                  menu.addAction("Action 1");
                  menu.addAction("Action 2");
                  menu.addAction("Action 3");
      
                  menu.exec(QCursor::pos());
              }
          }
      };
      
      ///////////////////////////////////////////////////////////////////////////
      Widget::Widget(QWidget *parent)
          : QWidget(parent)
      {
          setMinimumSize(500, 500);
          QPushButton* btn = new QPushButton("Press", this);
          btn->setGeometry(0, 0, 60, 30);
      
          MyDialog* dlg = new MyDialog(this);
          dlg->hide();
      
          connect(btn, &QPushButton::clicked, dlg, &MyDialog::exec);
      }
      
      Widget::~Widget()
      {
      }
      

      The above issue only happens when the menu is launched on a modal dialog. It does not happen on a modeless widget/dialog. The current workaround for this issue that I have found so far is to create the menu with a parent. For example,

      QMenu menu(this);
      

      So I would like to understand if this is a Qt bug or am I missing anything. It worked in Qt-5.4.1.
      Thanks in advance for the advice / help.

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        Which OS are you running your code on ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • Sivan
          Sivan last edited by

          Sorry forgot to mention that. I am running on MacOS Catalina 10.15.7

          1 Reply Last reply Reply Quote 0
          • Sivan
            Sivan last edited by

            Filed a bug in https://bugreports.qt.io/browse/QTBUG-94375

            1 Reply Last reply Reply Quote 1
            • AndyBrice
              AndyBrice last edited by

              For reference, see also:
              https://bugreports.qt.io/browse/QTBUG-88985

              1 Reply Last reply Reply Quote 0
              • First post
                Last post