.ico icons not showing up on Windows

蹲街弑〆低调 提交于 2019-11-28 12:08:19

For future google visitors: you may read comments under the question, because this is where this answer was born.

So the problem is that ico format is not supported by QIcon by default and you need a plugin for this. In such cases QImageReader::supportedImageFormats() function, which lists formats supported by QIcon may be helpful.

In case your format is not supported, you may try to copy imageformats folder from Qt's plugins directory into directory where your executable resides. If your app lies in c:\myapp folder you should have c:\myapp\imageformats folder (not c:\myapp\plugins\imageformats). Otherwise you have to set paths using QCoreApplication::addLibraryPath.

Also make sure that qico4.dll and qicod4.dll (if you build in debug mode) are there.

Just to elaborate on the QCoreApplication::addLibraryPath-thing:

You need to make the "plugins"-folder available. Not the subfolders!

Here is a way for Python/PySide users to use the PySide package location. You can also just use your QtGui.QApplication instance, which is app here, if you have one already:

pyside_plugin_path = os.path.join(sys.modules['PySide'].__path__[0], 'plugins')
app.addLibraryPath(pyside_plugin_path)

And thanks already to doc!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!