I fear it is too late by the time a context menu event has been sent. You did give me a hint that lead to:
m_ui->toolBar->setContextMenuPolicy(Qt::NoContextMenu);
// or
m_ui->toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
m_ui->toolBar->setContextMenuPolicy(Qt::NoContextMenu);
// or
m_ui->toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
To copy to clipboard, switch view to plain text mode
which I thought might work. The first but didn't seem to have any effect. The second stopped a context menu if clicked on the tool bar, but a context menu allowing hiding the tool bar would still come up if the right-click happened over the menu bar. I had to do:
setContextMenuPolicy(Qt::NoContextMenu);
setContextMenuPolicy(Qt::NoContextMenu);
To copy to clipboard, switch view to plain text mode
on the QMainWindow to stop both. Seems that the context menus on the menu and tool bars of a main window are delegated upward.
Bookmarks