Issue when loading an ico from a Qt resource file

后端 未结 5 2274
星月不相逢
星月不相逢 2020-12-21 05:31

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;
         


        
相关标签:
5条回答
  • 2020-12-21 05:34

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

    0 讨论(0)
  • 2020-12-21 05:41

    Guessing from your followup on the already chosen answer, you may want to have that ICO as the appwindow icon. That is possible, and also is perhaps why Qt Designer is capable of displaying it (trying to guess your intent). However, having it so doesn't involve any QPixmap coding, it's purely configuration affair. Described here (and yes, #worksforme) :

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

    0 讨论(0)
  • 2020-12-21 05:46

    The accepted answer here is incorrect, or as mentioned in the comments, at least misleading. Qt has come with a plugin for handling ICO format since sometime in version 4.4. Here's a similar question from the same era.

    For deployment, one needs to copy the plugins/imageformats/[lib]qico.[dll|so] file from the Qt installation used for building with to within their executable's directory. Put it in a subfolder, like so: <your_executable>/imageformats/qico.dll. If testing a debug build, the d suffix version of the lib is needed instead (qicod.dll).

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

    0 讨论(0)
  • 2020-12-21 05:47

    *.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

    0 讨论(0)
  • 2020-12-21 05:54

    you can convert it's format to Qt supported formats.

    0 讨论(0)
提交回复
热议问题