QML显示圆形图片

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

需要:

import QtGraphicalEffects 1.0

原文地址:https://www.cnblogs.com/judes/p/11245155.html