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