qml之通过OpacityMask 画圆形头象

qml之通过OpacityMask 画圆形头象_第1张图片
效果图片
import QtQuick 2.0
import QtGraphicalEffects 1.0
Item {
    Rectangle {
        id: _image
        width: 50
        height: 50
        Image {
            id: _source
            smooth: true
            visible: false
            anchors.fill: parent
            source: Qt.resolvedUrl("./images/1.jpg")
            sourceSize: Qt.size(parent.size, parent.size)
            antialiasing: true
        }
        Rectangle {
            id: _mask
            color: "black"
            anchors.fill: parent
            radius: width/2
            visible: true
            antialiasing: true
            smooth: true
        }
        OpacityMask {
            id:mask_image
            anchors.fill: _image
            source: _source
            maskSource: _mask
            visible: true
            antialiasing: true
        }
    }
}

你可能感兴趣的:(qml之通过OpacityMask 画圆形头象)