Search code examples
c++qtmenuwidgetmenubar

How to hide Qt widget application menu bar?


By default when creating a new Qt Widget project using Qt Creator. There's a menu bar, and it is shown always even without any menus, sub menus or actions. I don't want to delete this menu bar in designer view, just want to hide it only. Any solution?


Solution

  • try

    ui->menuBar->hide(); // hide menubar
    ui->menuBar->show(); // in case you want to restore it
    

    in your mainwindow class if you want to hide it in the runtime.

    Otherwise, you don't have to create a project with mainwindow.ui everytime. As you start a new project, there's an option in [Details]->[Base class] which allows you to choose the base class (template form) as mainwindow, dialog or widget.