Problem loading ico from Qt resource file

I am using Qt Designer 4.8.4 and I am including two files in the QMainWindow resource file: an .ico file and a .gif file. When loading from code use:

QPixmap p;
p.load(":/MyApp/media/logo.gif");  // does work
p.load(":/MyApp/media/logo.ico");  // does not work

      

The gif file works, but not the ico file. Is there any reason behind this? I am using an ico file as my window icon and it doesn’t show when the application starts.

And, YES, I am compiling the qrc file successfully as the GIF file is working .

Greetings,

+3


source to share


5 answers


*. ico is not supported.

By default, Qt supports the following formats:

Format Description Qt Support

BMP Windows Bitmap Read / Write

GIF graphic exchange format (optional). Read

Joint JPG Photo Experts Group Read / Write

JPEG Joint Photographic Expert Group Read / Write



PNG Network Graphics Portable Read / Write

Reading Portable PBM Bit File

PGM Portable Graymap Read

PPM Portable Pixmap Read / Write

TIFF Tagged Image File Format Read / Write

XBM X11 Bitmap Read / Write

XPM X11 Pixmap Read / Write

+5


source


Since QPixmap Cant just reads .ico files, take a look at the QPixmap documentation if you want to know more about the supported formats



+3


source


you can convert the format to Qt supported formats.

+2


source


Guessing from your subsequent answer on the already selected answer, you might want this ICO to be like an appwindow icon. It is possible, and perhaps this is why Qt Designer is able to display it (while trying to guess your intent). However, since this is not related to any QPixmap encoding, it is purely a matter of configuration. Described here (and yes, #worksforme):

http://doc.qt.digia.com/qt/appicon.html

+1


source


The accepted answer here is wrong or, as pointed out in the comments, is at least misleading. Qt comes with a plugin for handling ICO format since version 4.4. Here is a similar question from the same era.

To deploy, you need to copy plugins/imageformats/[lib]qico.[dll|so]

from the Qt installation used for the build to their executable directory. Place it in a subfolder, for example, as follows: <your_executable>/imageformats/qico.dll

. If you are testing a debug build, the suffix ( ) is qicod.dll

needed instead .qicod.dll

d

qicod.dll

( This new question has been flagged as a duplicate of this one, so now 2 questions point to the wrong answer. Which is why I'm essentially repeating my post here.)

0


source







All Articles