I don't know if this is normal or not, but 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.
Philippe
<<<<<<<<<<<<<<<<<
#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();
}
_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback