Details
-
Bug
-
Resolution: Invalid
-
P2: Important
-
None
-
6.2.0, 6.2.1, 6.6.2, 6.8.0
-
None
Description
When an SVG image is included in a .qrc file and loaded via QIcon(":/ns/filename.svg") constructor, no error is shown, but no image is displayed.
Attached is a project that demonstrate this behavior: in the window there are 2 buttons, one is set to an icon loaded from a png file, the other with a svg. Both are embedded via the qrc file in a shared library.
On Qt 5.15, both images are shown.
On Qt 6.2, only the one with png is shown.
On Qt 6.6.2, 6.8.0, neither image is shown.
Tested on Windows (MinGW). There are runtime warnings:
qt.svg: Cannot open file ':/image/drawing.svg', because: No such file or directory
Commenters suggest using Q_INIT_RESOURCES, but its documentation specifies that it needs to be used in static libraries, and the resources project in the example is a dynamic library.
On Linux, the same problem can be seen if libQt6Svg6 (or equivalent) is not installed.