View Full Version : mainwindow menubar setChecked

31st October 2007, 17:13

I would like an Action on a MainWindow menubar that is merely checkable but does not show a menu.

E.g when in the application example in mainwindow.cpp in createMenus() I add the following:

zoomMenu = menuBar()->addAction(tr("&Zoom"));
zoomMenu->setStatusTip(tr("Press then Left Click + rubberband + Richt Click"));
// zoomMenu->setEnabled(FALSE); //works

Then the 'Zoom' button shows up on the menubar but it is never checked.

Anybody knows why?

31st October 2007, 19:11
I don't know if it is actually possible to add QActions directly to the menu bar in this way. I've tried this in the past, but rendering was kind of messed up (not showing the text of buttons). You might have to extend the QMenuBar class to add that.

Also, C++ has a bool type for a reason.