Ok it took me a while to track this down, but I have no idea how to resolve it.
The main menu in my Qt/vtk application is behaving weirdly. Clicking behaviour on the menu is as follows:
- First click: pop down
- Second click: pop up
- Third click: does nothing
- Fourth click: pop down again
Now this wouldn't be that bad, but the problem is that the states are remembered. So if the user clicks the menu twice -- i.e., closes it manually -- the next click on the menu bar will not do anything, even if he used other GUI element in between. This leads to an annoying user experience.
I created a minimal failing example:
#include <QAction>
#include <QApplication>
#include <QLabel>
#include <QMainWindow>
#include <QMenu>
#include <QMenuBar>
#include <QVTKWidget.h>
int main(int argc, char** argv)
{
QApplication app(argc, argv);
QMainWindow mainWindow;
QMenu *menu = mainWindow.menuBar()->addMenu("TestMenu");
QAction *action = menu->addAction("TestAction");
// Setting the central widget to QVTKWidget, produces a weirdly
// behaving menu bar:
// First click: pop down
// Second click: pop up
// Third click: does nothing
// Fourth click: pop down again
mainWindow.setCentralWidget(new QVTKWidget());
// Setting the central widget to any other QWidget, like QLabel, produces a
// normally behaving menu bar:
// First click: pop down
// Second click: pop up
// Third click: pop down again
// mainWindow.setCentralWidget(new QLabel("TestLabel"));
mainWindow.show();
return app.exec();
}
If the QLabel-central-widget is commented in, and the QVTKWidget-central-widget is commented out, the menu is behaving normally.
Any ideas what to do next to resolve this?