Refresh QML Image



  • in my application i have an Image with source: "........"
    and a button beside to let the user the option to replace it with other image.
    in my qml file I added a function reload to the image as follow:
    @
    ....
    ....
    Image{
    ....
    ....
    source: "img.png"
    function reload()
    {
    source = ""
    source = "img.png"
    //the same path and name as before when user ask to replace the image I change the name of the image to be like the old image and overwrite the old image with the renamed image
    }
    }
    this works fine on windows (7) but on MAC it fail
    some one know why?
    Thanks
    @


  • Moderators

    Either a bug, or caching. Add this line to the definition:
    @
    cache: false
    @



  • thanks sierdzio but i have this line already
    acctually this how i define the image
    @
    Image{
    id:mLogo
    smooth: true
    source: "../../../Resources/data/clientLogo.png"
    width: 91
    height: 30
    fillMode: Image.PreserveAspectFit
    cache: false
    }
    @
    but it not help





  • Try to extract image source to property. than change this property.
    @
    property string src: "img.png"
    Image{
    source: src
    function reload()
    {
    src = "img1.png"
    }
    @


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.