QML显示圆形图片

Item {//一个圆形图片
    width: parent.width
    height: parent.height
    Image {
        id: rdJpg
        anchors.centerIn: parent
        smooth: true
        visible: false
        source: "qrc:/img/rd.jpg"
    }
    Rectangle {
        id: mask
        width: parent.width
        height: parent.height
        radius: width/2
        visible: false
    }
    OpacityMask {
        anchors.fill: parent
        source: rdJpg
        maskSource: mask
    }
}

需要:

import QtGraphicalEffects 1.0

 

 

 

posted @ 2019-07-25 16:33  朱小勇  阅读(555)  评论(0编辑  收藏  举报