Hiding Menu in MainWindow

I would like to hide one of my menu's in the main window in case it has no actions (this depends on whether certain plugins are loaded or not). Calling setVisible(false) on the QMenu does not hide it. So, what is the correct approach for this case?

It's the menu of the QMainWindow. This is how I created the QMenu with QMainWindow::menuBar()

AnalysisMenu = menuBar()->addMenu(tr("Analysis"));

Subsequently, I have some code that may or may not add QActions to this AnalysisMenu. For this I use QMenu::addAction. Finally, I have tried the following to hide the menu in case it does not have actions:

Yep, it also works correctly on Windows. It just does not work correctly on Ubuntu. It seems related to a menu problem that I experienced before on Ubuntu only. So, I guess that I will have to wait for a bug fix...