Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Hide QMainWindow from task bar and task switcher



  • Hello everyone,

    for my Qt application I want to create multipleMainWindows (derived from QMainWindow), but they should not appear in the task bar or in the task switcher (alt + tab). I found this stack overflow thread, but none of the suggested solutions worked.

    • Using a hidden QMainWindow as parent:
    QMainWindow hiddenParent;
    MainWindow window(&hiddenParent);
    window.show();
    

    The Window is still shown in the task bar and the task switcher.

    • Setting any combination of the Qt::Dialog, Qt::Tool and Qt::CustomizeWindowHint flags:
    MainWindow window(nullptr);
    window.setWindowFlags(Qt::Dialog | Qt::Tool | Qt::CustomizeWindowHint);
    window.show();
    

    The window does not show up at all, although the application is running, or the window is still visible in the task bar and the task switcher.

    • Setting the Qt::SubWindow flag:
    MainWindow window(nullptr);
    window.setWindowFlags(Qt::SubWindow);
    window.show();
    

    The Window is still shown in the task bar and the task switcher.

    • Setting the Qt::ToolTip flag:
    MainWindow window(nullptr);
    window.setWindowFlags(Qt::ToolTip);
    window.show();
    

    The window does not show up in the task bar or the task switcher, but it also loses the window decorations.

    Is using QMainWindows even the correct approach when I have multiple completely independent windows?
    I am working with Qt 6.0.2 on Ubuntu 20.04, however I also want to run the application on Windows.

    Thank you very much in advance!