1

How can I obtain the current system icon theme in a Qt application? I tried QIcon::themeName, but it just returns an empty string. (But QIcon::fallbackThemeName works?!) Is there some "special trick" to using this method I am missing, or some other way to obtain the current theme name?

Possibly related to this, but none of the answers there seem viable. (Edit: Okay, one of the methods there does work... after I fix the OP's typos . However, I'd prefer not relying on a Gnome-specific technique or needing to execute an external process.)

Matthew
  • 2,593
  • 22
  • 25
  • what is your desktop manager? – eyllanesc Apr 22 '20 at 14:29
  • An optimal answer would be desktop-agnostic. Qt must know how to get the theme regardless of desktop environment, since AFAIK icons work on all (XDG-ish) desktop environments. – Matthew Apr 22 '20 at 14:35
  • No, Qt does not support all desktop managers, and if your desktop manager is not supported then `QIcon::themeName()` returns an empty string as is your case.Read the docs: *On X11, the current icon theme depends on your desktop settings. **On other platforms it is not set by default.*** – eyllanesc Apr 22 '20 at 14:39
  • Okay, all ***X11*** desktops *that Qt supports*, then. At least GTK and KDE. For this purpose, I don't care about macOS and Windows, hence the [tag:linux] tag and clarification that I am asking about "XDG-ish" desktops. In particular, loading themed icons works and uses the correct theme, so *somewhere* Qt knows... – Matthew Apr 22 '20 at 14:47

0 Answers0