The preferred way would be to use QToolBar::toggleViewAction() in the menu bar. If you want to create a custom context menu, reimplement QMainWindow::createPopupMenu(). If you want to disable the context menu, you can set the context menu policy of the main window to Qt::NoContextMenu.