Zaxter
Zaxter

Reputation: 3035

Ubuntu SDK: How do I implement a “onClick” for an image in QML?

I have a background image for my page, and I want to implement a sort of page refresh when the background is clicked. However, I didn't find any actions for the image element in QT quick.

What's the right way to implement this?

Upvotes: 2

Views: 4184

Answers (1)

koopajah
koopajah

Reputation: 25612

You need to use MouseArea to handle click events.

Image {
    source: "myimage.png"

    MouseArea {
        anchors.fill: parent
        onClicked: {
            // do what you want here
        }
    }
}

Upvotes: 7

Related Questions