Hide OSX menu bar from Qt Application?



  • I want to hide OSX Menu bar and OSX Dock panel. I tried to use this code:

    int main(int argc, char *argv[]) {
      QApplication app(argc, argv);
      QDialog* dlg = new QDialog();
      QPushButton* btn = new QPushButton(this);
    	connect(btn, &QPushButton::clicked, [this](){
      	[NSApp setPresentationOptions: [NSApp presentationOptions] | NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock];
    	})
    	dlg->show();
      return app.exec();
    }
    

    This code hides Dock panel, but doesn't hide Menu bar. by experimentation it was found that the menu does not disappear because Application launched as agent with Info.plist option:

    		<key>LSUIElement</key>
    		<string>1</string>
    

    If I delete LSUIElement, OSX Dock and Menu bar will be hided, but I don't want that Application has been shown in Dock.

    I don't want to use full screen mode dlg->setFullscreen() bexause it creates new OSX screen.

    How to doesn't show Application in Dock and hide OSX Menu Bar and Dock panel when Application is active?


  • Lifetime Qt Champion

    Hi,

    Out of curiosity, can you describe what your application does that it needs all of these elements hidden ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.