Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Window that does not appear in taskbar and can't alt tab on
Qt 6.11 is out! See what's new in the release blog

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

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 2 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    reonZ
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      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;
      }
      
      R 1 Reply Last reply
      3
      • hskoglundH hskoglund

        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;
        }
        
        R Offline
        R Offline
        reonZ
        wrote on last edited by
        #3

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

        1 Reply Last reply
        3
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          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.

          R 1 Reply Last reply
          1
          • hskoglundH hskoglund

            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.

            R Offline
            R Offline
            reonZ
            wrote on last edited by
            #5

            @hskoglund It seems to be working quite well.

            1 Reply Last reply
            2

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved