This is safer, faster and compile time checked
It should be setVisible on QMenuBar not on MainWindow
toggleMenuBarAction = KStandardAction::showMenubar(menuBar(), &QMenuBar::setVisible, collection);
Are you working on this? I can help along if you want.
I forgot this for quite a while, I'll update today.
Looks like this needs up looked at - moved to invent MR