0

I want to catch the click on my QMenuBar that is in QMainWindow, so I have subclassed QMenuBar and I have overrided the mousePressEvent function, but now when I click on menu, the submenus doesn't display them.

An idea ?

Marc Lamberti
  • 763
  • 2
  • 9
  • 24

1 Answers1

1

In the end of your mousePressEvent function you should pass the event to the base class, which will do its own operations on mouse click:

void MyMenu::mousePressEvent(QMouseEvent *event)
{
    // do your stuff
    QMenu::mousePressEvent(event);
}

Here you can read about the Qt Event System.

hank
  • 9,553
  • 3
  • 35
  • 50