import QtQuick 2.15
import QtQuick.Window 2.15
Window {
width: 640
height: 480
visible: true
title: qsTr("Hello World")
Canvas{
id:mycanvas
width: 200
height: 200
onPaint: {
var ctx = getContext("2d");
//ctx.fillStyle = "green"//填充
ctx.strokeStyle = "blue"//邊線
ctx.lineWidth = 4 //邊線寬度
ctx.lineJoin = "round" //邊線連接配接樣式(圓弧将拐角連接配接起來)
ctx.fillRect(20,20,160,160) //填充矩形
ctx.clearRect(30,30,140,140)//清空矩形
ctx.strokeRect(20,20,80,80) //以描邊方式繪制矩形
}
}
}