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

zooming an SVG image



  • Hi,

    An SVG image is scalable and hence, when zooming in, I should still be able to see a crisp sharp image.
    I first tried the following:

    Image {
            id:svgImage
            anchors.fill: parent
            fillMode: Image.PreserveAspectFit
            source: "./pentathlon.svg"
            smooth: false
            scale: 1.0
            transformOrigin: Item.Top
            //sourceSize.height: parent.height*scale
            //sourceSize.width: parent.width*scale
            MouseArea {
                anchors.fill: parent
                onClicked: svgImage.scale *= 2
            }
        }
    

    This scaled fast but after a few clicks, the image was pixelated.
    When uncommenting the two sourceSize lines, the image remained sharp but at the expense of a lot of memory and CPU.

    Is there a way to limit memory usage/CPU consumption without sacrificing sharpness?

    Thanks in advance,

    Marc