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. What operating systems support QApplication setWindowIcon?
Forum Updated to NodeBB v4.3 + New Features

What operating systems support QApplication setWindowIcon?

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 4 Posters 694 Views 2 Watching
  • 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.
  • P Offline
    P Offline
    Publicnamer
    wrote on 24 Dec 2021, 10:55 last edited by Publicnamer
    #1

    On Linux, I can do the following at any time and have the X Windows icon change immediately:

        QPixmap pixmap(myPixmap_xpm);
        QIcon icon(pixmap);
        myApp->setWindowIcon (icon);
    

    This doesn't affect what Xfce shows in an app launcher but it does change the smaller icon that appears:

    • at the top/left of each window.
    • in the Window Buttons panel.

    What other operating systems allow this immediate affect? I'm under the impression that MacOS doesn't.
    What about Windows?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 24 Dec 2021, 20:10 last edited by
      #2

      Hi,

      There are some conditions on macOS that are explained in the documentation of the property.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      P 1 Reply Last reply 25 Dec 2021, 15:01
      0
      • S SGaist
        24 Dec 2021, 20:10

        Hi,

        There are some conditions on macOS that are explained in the documentation of the property.

        P Offline
        P Offline
        Publicnamer
        wrote on 25 Dec 2021, 15:01 last edited by
        #3

        @SGaist I see that it says "This property only makes sense for windows".
        They should update the document to mention it works on Linux.

        Also, on Windows, does the Taskbar get updated with the new icon?

        J 1 Reply Last reply 25 Dec 2021, 19:15
        0
        • C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 25 Dec 2021, 16:57 last edited by
          #4

          "This property only makes sense for windows" - the doc means windows, as in top level widgets, not Windows, as in operating system name.

          And yes, it works on Windows (the OS) and taskbar icon is changed.

          1 Reply Last reply
          3
          • P Publicnamer
            25 Dec 2021, 15:01

            @SGaist I see that it says "This property only makes sense for windows".
            They should update the document to mention it works on Linux.

            Also, on Windows, does the Taskbar get updated with the new icon?

            J Offline
            J Offline
            JonB
            wrote on 25 Dec 2021, 19:15 last edited by
            #5

            @Publicnamer
            You can safely assume that in the Qt docs windows refer to the things made of glass while Windows refers to the thing made of glass produced by Microsoft :)

            P 1 Reply Last reply 25 Dec 2021, 20:43
            0
            • J JonB
              25 Dec 2021, 19:15

              @Publicnamer
              You can safely assume that in the Qt docs windows refer to the things made of glass while Windows refers to the thing made of glass produced by Microsoft :)

              P Offline
              P Offline
              Publicnamer
              wrote on 25 Dec 2021, 20:43 last edited by Publicnamer
              #6

              That sounds good re Windows' Taskbar.

              I wonder if there's any workaround for the Mac dock. I assume the Dock is a separate process, same with GNUStep's dock, but I wonder if a connection can be made to it in order to send a new icon to it at runtime?

              1 Reply Last reply
              0
              • S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 25 Dec 2021, 20:47 last edited by
                #7

                You can using NSDockTile.

                What exactly are you trying to achieve ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                P 1 Reply Last reply 25 Dec 2021, 20:53
                0
                • S SGaist
                  25 Dec 2021, 20:47

                  You can using NSDockTile.

                  What exactly are you trying to achieve ?

                  P Offline
                  P Offline
                  Publicnamer
                  wrote on 25 Dec 2021, 20:53 last edited by Publicnamer
                  #8

                  @SGaist I want to update the App icon at runtime e.g. to add graphics to it. E.g. imagine a dock icon that implements xload's window showing the system load graph.

                  I see here NSDockTile's used in Qt's MacOS code. But that appears to be code that's intended to help Chrome's authors.

                  void DevToolsDockTile::Update(const std::string& label, gfx::Image image) {
                    NSDockTile* dockTile = [[NSApplication sharedApplication] dockTile];
                    if (!image.IsEmpty()) {
                      NSRect imageFrame = NSMakeRect(0, 0, 0, 0);
                      base::scoped_nsobject<NSImageView> imageView(
                          [[NSImageView alloc] initWithFrame:imageFrame]);
                      NSImage* nsImage = image.ToNSImage();
                      [imageView setImage:nsImage];
                      [dockTile setContentView:imageView];
                    }
                    [dockTile setBadgeLabel:base::SysUTF8ToNSString(label)];
                    [dockTile display];
                  }
                  
                  
                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 27 Dec 2021, 16:19 last edited by
                    #9

                    If you want to customize the dock tile then you'll have to use the native API.

                    From the looks of it, create a QImage, draw whatever you want on it, convert to a NSImage and set it on the tile.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply
                    0

                    1/9

                    24 Dec 2021, 10:55

                    • Login

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