本文主要是介绍Qt_Note20_QML_自定义Grid控件与OpacityMask的使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
import QtQuick 2.12
import QtQuick.Window 2.12
import QtQuick.Controls 2.12
import QtGraphicalEffects 1.14Window {visible: truewidth: 640height: 480title: qsTr("Hello World")// 自定义Grid控件与OpacityMask的使用Grid {id: gridwidth: 15height: 200columns: 3x: 300y: 100visible: false //看不到了Repeater {
// model: grid.width / 5 * grid.height / 5model: grid.width / 5 * 200 / 5Rectangle {width: 5height: 5color: index % 2 ? "black" : "white"Component.onCompleted: {console.log("rect" + index)}}}}Rectangle {id: maskRectx: 200y: 100width: grid.widthheight: grid.heightvisible: trueradius: 10border.color: "red"}Button {width: 50height: 50x: 100y: 100onClicked: {grid.height -= 10}}Rectangle{width: grid.width + 4height: grid.height + 4
// anchors.centerIn: parentanchors.horizontalCenter: parent.horizontalCenteranchors.bottom: parent.bottomborder.color: "red"radius: 10border.width: 3OpacityMask {source: gridmaskSource: maskRectanchors.fill: parentanchors.margins: 2}}}
这篇关于Qt_Note20_QML_自定义Grid控件与OpacityMask的使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!