1、概述
源码放在文章末尾
该项目实现了图像的发光效果,特别适合做头像,项目demo演示如下所示:
项目部分代码如下所示:
import QtQuick 2.7
import QtGraphicalEffects 1.12Item
{id: rootwidth: 80height: 80property int radius: width >> 1; //默认宽度的一半property alias source: image.source;property alias mipmap: image.mipmap;property alias fillMode: image.fillMode;Image{id: imagesourceSize: Qt.size(parent.width, parent.height)mipmap: truevisible: false}Rectangle{id: maskanchors.fill: parentradius: root.radiusvisible: false}OpacityMask{anchors.fill: parentsource: imagemaskSource: mask}
}