Problem with QIcon::fromTheme()
-
from docs:
"Or if you want to provide a guaranteed fallback for platforms that do not support theme icons, you can use the second argument:" @QIcon undoicon = QIcon::fromTheme("edit-undo", QIcon(":/undo.png"));@ so on Windows will be used only fallback icons, right?
But if I use such code in my .pro file:
@win32:RESOURCES += icons.qrc@
I get such errors on Linux:
@Cannot open file ':/undo.png', because: Unknown error@How to tell Qt use system icons on linux and icons from resource on Windows?
Thanks. -
Of course all icons presents in resource file.
But if I'm on Linux - I do not want to compile resource into binary, I want to use system icons only. -
Ah, sorry, I misread the first post. The default icon must be provided as a ready-to-use icon. So, if you do not provide the resource file on Linux, the icon cannot be created - hence the error message. So you would either need to #ifdef the code and leave out the default for Linux or add your default set of icons to the resource file on Linux too. I would go for the latter, as I would not bet that in any and every case you'll have system icons on Linux too, so providing your default set is a good idea. The additional size is negligible, in my opinion.