QIcon from theme feature
-
wrote on 18 May 2021, 15:31 last edited by
I've try to use icon from theme, like this
QIcon icon = QIcon::fromTheme(QStringLiteral("view-refresh"));
On Linux is okay but on Windows is nothing. Why?
Ok, what the strange myth of string "view-refresh"? Looking at https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html I found the hard coded theme names for free desktop.
Is it OS specific? Or OS desktop manager specific? How can I fix it qiuckly particular on Windows? :-)
Thanks a lot guys, that forum is very useful for beginers and expirienced user of Qt exactly!
-
wrote on 18 May 2021, 15:58 last edited by
What version of Qt are you using?
-
wrote on 18 May 2021, 16:22 last edited by
@VRonin 5.12.9
-
wrote on 18 May 2021, 16:40 last edited by
Windows does not have a platform theme, you can create a custom one based on something like this example.
You can take Icons from KDE's Breeze or Oxygen, they use LGPL 3 as license -
Windows does not have a platform theme, you can create a custom one based on something like this example.
You can take Icons from KDE's Breeze or Oxygen, they use LGPL 3 as licensewrote on 19 May 2021, 05:52 last edited by@VRonin Oh thank you. But how it works? I need create theme and include it in my project and distribute package?
-
@VRonin Oh thank you. But how it works? I need create theme and include it in my project and distribute package?
wrote on 19 May 2021, 10:26 last edited by VRonin@Alexey-Serebryakov said in QIcon from theme feature:
I need create theme and include it in my project and distribute package?
Yes, for example, for breeze icons using MinGW, clone the repository (git clone https://invent.kde.org/frameworks/breeze-icons.git) then run
mkdir build && cd build cmake -G"MinGW Makefiles" -DCMAKE_BUILD_TYPE=RELEASE ../ cmake --build .
(for MSVC replace
MinGW Makefiles
withNMake Makefiles
)Now in build\icons\res edit with notepad breeze-icons.qrc and change the second line from
<qresource>
to<qresource prefix="icons/Breeze">
Finally move all the contents of this folder into your project and addbreeze-icons.qrc
as a resource to it.
Make sure you also distribute the license file with your app to comply with LGPL 3.
To use it when the platform theme is not available, in yourmain()
add:if (QIcon::themeName().isEmpty()) QIcon::setThemeName("Breeze");
1/6