简体   繁体   English

Ubuntu SDK:如何在QML中为图像实现“ onClick”?

[英]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. 但是,我在QT中没有找到针对图像元素的任何操作。

What's the right way to implement this? 什么是实现此目标的正确方法?

You need to use MouseArea to handle click events. 您需要使用MouseArea处理单击事件。

Image {
    source: "myimage.png"

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM