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

Window that does not appear in taskbar and can't alt tab on



  • I would like to Create a window that has all the normal properties of a QMainWindow but would not appear in the taskbar and that you can not alt tab over.



  • Hi, you can use the old ToolWindow style, to try, create an empty vanilla Widget app, add this to the .pro file:

    LIBS += -luser32
    

    Then change mainwindow.cpp to this:

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    #include "Windows.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    
        HWND hWnd = reinterpret_cast<HWND>(winId());
        LONG_PTR exStyle = GetWindowLongPtr(hWnd,GWL_EXSTYLE);
        SetWindowLongPtr(hWnd,GWL_EXSTYLE,exStyle | WS_EX_TOOLWINDOW);
    
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    


  • @hskoglund I see, it gives the same result as doing setWindowFlag(Qt::Tool).



  • Yes you're right, didn't know about that flag. Also easier than have to #include "windows.h" etc.

    Anyways, hope that this ToolWindow style is what you're looking for.



  • @hskoglund It seems to be working quite well.


Log in to reply