What operating systems support QApplication setWindowIcon?
-
wrote on 24 Dec 2021, 10:55 last edited by Publicnamer
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? -
Hi,
There are some conditions on macOS that are explained in the documentation of the property.
-
Hi,
There are some conditions on macOS that are explained in the documentation of the property.
wrote on 25 Dec 2021, 15:01 last edited by@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?
-
"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.
-
@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?
wrote on 25 Dec 2021, 19:15 last edited by@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 :) -
@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 :)wrote on 25 Dec 2021, 20:43 last edited by PublicnamerThat 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?
-
You can using NSDockTile.
What exactly are you trying to achieve ?
-
You can using NSDockTile.
What exactly are you trying to achieve ?
wrote on 25 Dec 2021, 20:53 last edited by Publicnamer@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]; }
-
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.
1/9