Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

HI-DPI and SVG icons



  • I am attempting to use Qt 5.6.0's HI-DPI support. I'm using SVGs on my icons. I was hoping that for HI-DPI, the SVGs would scale cleanly. Unfortunately, it appears that the SVGs are rendered to the pixmap first and then the pixmap is scaled to a size appropriate for the HI-DPI screen. This then produces blurry images. Is there some way to force the SVGs rendering to be applied after the output size is specified. Basically, I'd like the pixmap size to change first then the SVG render to occur so that the SVG can be rendered directly and cleanly to the new size.

    Anyone know how to accomplish this (if it's even possible)?



  • Follow up (many years later). The problems I was having with SVG scaling were not a Qt problem but a problem with the dimensions of the SVG. The dimensions need to be a factor of 4 for clean scaling. My SVGs were based on legacy code and had dimensions of 26x29 pixels. Changing to 24x28 fixed everything right up.



  • if using qml, sourceSize (sourceWidth and sourceHeight) will change svg scale first, then draw it on Image pixmap



  • Thanks for the reply. Unfortunately I'm using QWidgets and not qml.



  • Follow up (many years later). The problems I was having with SVG scaling were not a Qt problem but a problem with the dimensions of the SVG. The dimensions need to be a factor of 4 for clean scaling. My SVGs were based on legacy code and had dimensions of 26x29 pixels. Changing to 24x28 fixed everything right up.


  • Lifetime Qt Champion

    @Mark-A.-Green
    Congrats. Best come back i have seen so far :)


  • Moderators

    Now here's a rare case where necro-posting is completely appropriate and appreciated :-D


Log in to reply