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

Iconsistent icon size in QAction when using SVG images compared to PNG images



    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.6, 6.1.3
    • None
    • Tested in Windows 10 but other systems could be affected too.
    • Windows


      I am trying to replace the PNG icons in my app with SVG versions to fully support scalable UI. My app is already able to scale properly (e.g. when Windows scale settings are above 100%), but I have 1x icons so they look blurry at higher scales.

      I've found that the behavior when using SVG icons in QAction + QToolBar + context menu is inconsistent with the PNG images behavior.

      I want to replace a 9x12px PNG with a SVG image with a view box with 9x12 size, the problem is that the tool bar won't respect that size and it will make the SVG image take all the available size.

      I tried creating a SVG version with a view box that matches the toolbar icon size (by adding padding to it), but then the size in the context menu is wrong.

      What I expect is that both PNG and SVG images look the same size in the toolbar and then context menu, and that the SVG will look crisp at scales bigger than 100%. The toolbar or the toolbar button is able to center the PNG image into the 18x18 icon size, but the SVG just takes all the available size (keeping the aspect ratio) ignoring the view box or width/height properties.

      Check attached screenshot and project for more details. The screenshots were taken at 100% and 200% screen scale in Windows.



        1. screenshot.png
          21 kB
        2. screenshot - 100%.png
          screenshot - 100%.png
          8 kB
        3. svg-sizing.zip
          21 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.



            qt.team.quick.subscriptions Qt Quick and Widgets Team
            luisangelsm Luis Ángel San Martín
            0 Vote for this issue
            3 Start watching this issue



              Gerrit Reviews

                There are no open Gerrit changes