Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue when loading an ico from a Qt resource file

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

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? I am using the ico file as the window icon and it is not showing when running the application.

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

Cheers,

like image 383
Didac Perez Parera Avatar asked Dec 12 '22 18:12

Didac Perez Parera


2 Answers

*.ico is not supported.

By default, Qt supports the following formats:

Format Description Qt's support

BMP Windows Bitmap Read/write

GIF Graphic Interchange Format (optional) Read

JPG Joint Photographic Experts Group Read/write

JPEG Joint Photographic Experts Group Read/write

PNG Portable Network Graphics Read/write

PBM Portable Bitmap Read

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

like image 123
Leo Chapiro Avatar answered Dec 14 '22 06:12

Leo Chapiro


Because QPixmap Cant read .ico files simply, take a look at documentation QPixmap if you want to know more about formats supported

like image 33
Filippo Savi Avatar answered Dec 14 '22 06:12

Filippo Savi