QIcon from theme feature
-
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!
-
@VRonin 5.12.9
-
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@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?
@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");