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

How to resize a *.png* image in a QML code



  • Hi all,

    For an image in a QML project, I need to have some manipulation which is resizing that image so that it meets the needs for its appearance.
    I use these:

    Image {
            id: background
            source: "qrc:/images/background.png"
            paintedWidth: 200
            paintedHeight: 200
           // fillMode: Image.PreserveAspectFit
    
        }
    

    But it doesn't have any effect on the actual image when the program is run.



  • hi
    @tomy said in How to resize a *.png* image in a QML code:

    paintedWidth: 200
    paintedHeight: 200
    

    set

    width: 200
    height: 200
    


  • @LeLev
    Thanks so much.
    It solved the problem.
    At the commencement, I didn't test this because I thought it's very easy and couldn't work! So I went after the advanced stuff written above but it was them which didn't work in effect and this easy version is very handy! :)


Log in to reply