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. Qt on windows: Avoid the Taskbar Icon

Qt on windows: Avoid the Taskbar Icon

Scheduled Pinned Locked Moved General and Desktop
11 Posts 6 Posters 21.8k 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
    ronM71
    wrote on 17 Aug 2011, 21:41 last edited by
    #1

    It seems that only by assigning Qt::Popup or Qt::Tool to a QWidget, am I able to avoid the windows taskbar Icon for my window.

    The problem is that with Qt::Popup, the window is frameless, and with Qt::Tool it's tiny and has only the "close" button, like any other traditional tool window.

    How can I have a normal frame to my window AND keep it out of the taskbar?

    1 Reply Last reply
    0
    • 9 Offline
      9 Offline
      90000
      wrote on 18 Aug 2011, 00:57 last edited by
      #2

      you can try Qt::Dialog.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        ronM71
        wrote on 18 Aug 2011, 01:07 last edited by
        #3

        I did... i'm still getting the taskbar icon

        1 Reply Last reply
        0
        • 9 Offline
          9 Offline
          90000
          wrote on 18 Aug 2011, 01:10 last edited by
          #4

          sorry it's wrong。

          1 Reply Last reply
          0
          • 9 Offline
            9 Offline
            90000
            wrote on 18 Aug 2011, 01:14 last edited by
            #5

            QWidget *hideWidget = new QWidget();
            //don't show it

            QDialog *test = new QDialog(hideWidget);
            test->show();

            this method works for me, in win7.

            but you can still get the window by ALT+TAB

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lgeyer
              wrote on 18 Aug 2011, 06:43 last edited by
              #6

              As far as I know there are two other options (besides setting Qt::Tool)

              • set an invisible / hidden window as parent window
              • remove the WS_EX_APPWINDOW style from the window
                @
                #include "qt_windows.h"

              WId id = widget->winId();

              ShowWindow(id, SW_HIDE);
              SetWindowLong(id, GWL_EXSTYLE, GetWindowLong(id, GWL_EXSTYLE) | ~WS_EX_APPWINDOW);
              ShowWindow(id, SW_SHOW);
              @
              Brain to terminal. Not tested.

              1 Reply Last reply
              0
              • G Offline
                G Offline
                giesbert
                wrote on 18 Aug 2011, 07:46 last edited by
                #7

                [quote author="Lukas Geyer" date="1313649797"]

                • set an invisible / hidden window as parent window
                  [/quote]

                How to do this? AFAIK, If the parent widget is invisible, you are also invisble. And using an invisible HWND as parent window might get complicated, as you have no access to createWnd call...it's done implicitly onside QWidget...

                [quote author="Lukas Geyer" date="1313649797"]* remove the WS_EX_APPWINDOW style from the window
                [/quote]

                As we already had this issue, I tried this out and found, it does not work :-( It can be used to show/hide the window in combination with the invisible parent HWND.

                Nokia Certified Qt Specialist.
                Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                1 Reply Last reply
                0
                • L Offline
                  L Offline
                  lgeyer
                  wrote on 18 Aug 2011, 08:20 last edited by
                  #8

                  [quote author="Gerolf" date="1313653594"][quote author="Lukas Geyer" date="1313649797"]

                  • set an invisible / hidden window as parent window
                    [/quote]

                  How to do this? AFAIK, If the parent widget is invisible, you are also invisble. And using an invisible HWND as parent window might get complicated, as you have no access to createWnd call...it's done implicitly onside QWidget...[/quote]

                  The following code does not show a taskbar icon.
                  @
                  int main(int argc, char *argv[])
                  {
                  QApplication application(argc, argv);

                  QWidget widget;
                  QMainWindow mainWindow(&widget);
                  
                  mainWindow.show();
                  
                  return application.exec();
                  

                  }
                  @

                  [quote author="Gerolf" date="1313653594"][quote author="Lukas Geyer" date="1313649797"]* remove the WS_EX_APPWINDOW style from the window[/quote]

                  As we already had this issue, I tried this out and found, it does not work :-( It can be used to show/hide the window in combination with the invisible parent HWND.[/quote]

                  bq. The rules the taskbar uses to decide whether a button should be shown for a window are really quite simple, but are not well documented. When you create a window, the taskbar examines the window's extended style to see if either the WS_EX_APPWINDOW (defined as 0x00040000) or WS_EX_TOOLWINDOW (defined as 0x00000080) style is turned on. If WS_EX_APPWINDOW is turned on, the taskbar shows a button for the window, and if WS_EX_ TOOLWINDOW is turned on, the taskbar does not show a button for the window. You should never create a window that has both of these extended styles.
                  You can create a window that doesn't have either of these styles. If a window has neither style, the taskbar decides to create a button if the window is unowned and does not create a button if the window is owned.
                  One final note: before making any of the above tests, the taskbar first checks to see if a window has the standard WS_VISIBLE window style turned on. If this style bit is off, the window is hidden; the taskbar never shows a button for a hidden window. Only if the WS_VISIBLE style bit is on will the taskbar check the WS_EX_APPWINDOW, WS_ EX_TOOLWINDOW, and window ownership information.

                  In addition, if I remember correctly this is how the CLRs ShowInTaskbar property is implemented.

                  The following code does not show a taskbar icon, BUT it leads to an unusable tool-like window.
                  @
                  int main(int argc, char *argv[])
                  {
                  QApplication application(argc, argv);

                  QMainWindow mainWindow;
                  
                  mainWindow.show();
                  
                  ShowWindow(mainWindow.winId(), SW_HIDE);
                  SetWindowLong(mainWindow.winId(), GWL_EXSTYLE, GetWindowLong(mainWindow.winId(), GWL_EXSTYLE) | ~WS_EX_APPWINDOW);
                  ShowWindow(mainWindow.winId(), SW_SHOW);
                  
                  return application.exec();
                  

                  }
                  @

                  Yes, it looks like removing the WS_EX_APPWINDOW style unfortunately does not work as expected and is not a viable solution.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    giesbert
                    wrote on 18 Aug 2011, 08:25 last edited by
                    #9

                    [quote author="Lukas Geyer" date="1313655612"][quote author="Gerolf" date="1313653594"][quote author="Lukas Geyer" date="1313649797"]

                    • set an invisible / hidden window as parent window
                      [/quote]

                    How to do this? AFAIK, If the parent widget is invisible, you are also invisble. And using an invisible HWND as parent window might get complicated, as you have no access to createWnd call...it's done implicitly onside QWidget...[/quote]

                    The following code does not show a taskbar icon.
                    @
                    int main(int argc, char *argv[])
                    {
                    QApplication application(argc, argv);

                    QWidget widget;
                    QMainWindow mainWindow(&widget);
                    
                    mainWindow.show();
                    
                    return application.exec();
                    

                    }
                    @
                    [/quote]

                    That's interesting, I never tried it.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • T Offline
                      T Offline
                      texpert
                      wrote on 15 Jul 2014, 06:34 last edited by
                      #10

                      setWindowFlags not to Qt::Tool, but to Qt::ToolTip did the trick

                      Sincerely yours, amigos!

                      1 Reply Last reply
                      3
                      • A Offline
                        A Offline
                        Ansen
                        wrote on 9 Sept 2024, 09:23 last edited by
                        #11

                        When set ToolTip, the window can not be dragged.
                        And when recoding the mouseMoveEvent, the window loss some event.

                        1 Reply Last reply
                        0
                        • J.HilkJ J.Hilk locked this topic on 9 Sept 2024, 10:37

                        • Login

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