Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt on windows: Avoid the Taskbar Icon

    General and Desktop
    5
    10
    20492
    Loading More Posts
    • 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
      ronM71 last edited by

      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 Reply Quote 0
      • 9
        90000 last edited by

        you can try Qt::Dialog.

        1 Reply Last reply Reply Quote 0
        • R
          ronM71 last edited by

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

          1 Reply Last reply Reply Quote 0
          • 9
            90000 last edited by

            sorry it's wrong。

            1 Reply Last reply Reply Quote 0
            • 9
              90000 last edited by

              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 Reply Quote 0
              • L
                lgeyer last edited by

                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 Reply Quote 0
                • G
                  giesbert last edited by

                  [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 Reply Quote 0
                  • L
                    lgeyer last edited by

                    [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 Reply Quote 0
                    • G
                      giesbert last edited by

                      [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 Reply Quote 0
                      • T
                        texpert last edited by

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

                        Sincerely yours, amigos!

                        1 Reply Last reply Reply Quote 3
                        • First post
                          Last post