Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97913

SVG icons doesn't work as embedded resource in Qt6

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P2: Important
    • None
    • 6.2.0, 6.2.1, 6.6.2, 6.8.0
    • Core: Plugins
    • None
    • Windows

    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.

      Attachments

        1. image-2024-10-14-00-40-45-450.png
          6 kB
          Dat Ng
        2. test_qrc_qt6_2024.10.14.zip
          20 kB
          Dat Ng
        3. video.zip
          24.49 MB
          Alan Fan
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            thiago Thiago Macieira
            uthidata Dat Ng
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes