Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
None
-
5.15.2
-
None
-
-
ae3594436b9b0540ef94379a73bf8fec8d3b7465
Description
Could not hover on a menu which is executed from a modal dialog.
Here is the 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() { }
1) Compile and run the above code
2) Click on the press button to open the dialog.
3) On the dialog, right click and try to hover on the actions.
4) Notice it is not possible to hover
The only workaround that I have found so far is to create the menu in modal dialog with a parent. For example:
QMenu menu(this);
This issue does not happen on a modeless dialog or widget