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

REG: QMenu::exec() regression

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 4.7.0
    • 4.7.0
    • None
    • Windows 7
    • 08e2c776bf2ce6976276bcdcce342ae8c4675565

    Description

      The following has changed in 4.7 compared to previous versions:

      The following code:

      QMenu popupMenu(0);
      popupMenu.addAction("Some action");
      popupMenu.exec(QCursor::pos());

      causes the active window to deactivate. This was not the case in 4.6
      To behave like 4.6, one has to do:

      QMenu popupMenu(someParentWidget); // watch
      popupMenu.addAction("Some action");
      popupMenu.exec(QCursor::pos());

      Why not, but if this is normal now, I think that the parent argument of the QMenu ctor should not be 0 any more, because that leads to a non-desirable effect.

      Here's a small application that reproduces what I have described here.
      This was tested under Windows with 4.7b1.

      <<<<<<<<<<<<<<<<<

      #include <QtGui/QtGui>

      class TWidget : public QWidget
      {
      public:
      TWidget(QWidget* parent) : QWidget(parent) {}
      void mousePressEvent(QMouseEvent* ev);
      };

      void TWidget::mousePressEvent(QMouseEvent* ev)
      {
      if (ev->button() == Qt::RightButton)

      { QMenu popupMenu(0); popupMenu.addAction("Some action"); popupMenu.exec(QCursor::pos()); }

      }

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      QMainWindow w;

      TWidget* le = new TWidget(&w);
      w.setCentralWidget(le);
      w.show();

      return a.exec();
      }

      Attachments

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

        Activity

          People

            bachewii Jens
            jirauser26727 user-04d21 (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes