In Qt, if I right-click on a toolbar the menu will be shown that allows me to hide the toolbar. I need to disable this functionality because I don't want the toolbar to possible to hide. Is there a way to do this?
I was able to set the ContextMenuPolicy directly on the toolbar (not the main window), as long as I used either Qt::PreventContextMenu
or Qt::ActionsContextMenu
. Prevent
eliminated the context menu and made right-click have no effect on the toolbar, while Actions
made a nice context menu composed of the actions already in my toolbar. Qt::NoContextMenu
didn't seem to have any effect.
toolbar->setContextMenuPolicy(Qt::PreventContextMenu);