3

I am using Qt Quick 2 and would like a QML image to be updated when the source is change via clicked on the image. But can't get that to happen.

There have been a few similiar questions but those solutions have not brought any joy in my case. Both images are added to the solution and I can set the image to either. Just can't update the image after changing the source.

Thanks in advance

 Image {
    id : two_player_button
    x: 24
    y: 105
    cache : false
    fillMode: Image.PreserveAspectCrop
    z: 1
    sourceSize.height: 0
    sourceSize.width: 0
    source: "resources/base/players_2.png"

    MouseArea {

        anchors.fill: parent
        onClicked: {
            source: "resources/base/players_2_hl.png"
            //two_player_button.update()
        }
    }
 }

I have also tried updating it via the parent.

Willeman
  • 720
  • 10
  • 24

1 Answers1

1

Found my own mistake finally:

needed to be

two_player_button.source = "resources/base/players_2_hl.png"

Just saying

source = "resources/base/players_2_hl.png" 

would also not have worked and sets the parent source.

Willeman
  • 720
  • 10
  • 24