如题,画了一条直线,拉伸窗体时,直线
显示的区域
没有变,还是初始大小,不知道为什么,
求助代码
import QtQuick 2.2
Rectangle
{
id: chart
width: 600
height: 400
color: "transparent"
Canvas
{
id: canvas
anchors.fill:parent
function drawLine(x1,y1,x2,y2,ctx)
{
ctx.save();
ctx.fillStyle="#ffffffff";
ctx.fillRect(0,0,canvas.width,canvas.height);
ctx.strokeStyle ="#ffff0000";
ctx.beginPath();
ctx.moveTo(x1,y1);
ctx.lineTo(x2,y2);
ctx.closePath();
ctx.stroke();
ctx.restore();
}
onPaint:
{
var ctx=canvas.getContext("2d");
ctx.globalCompositeOperation="source-over";
ctx.lineWith=1;
console.log("width="+canvas.width+" height="+canvas.height);
console.log(canvas.canvasSize)
console.log(canvas.canvasWindow);
console.log(canvas.available);
console.log(canvas.tileSize);
console.log(canvas.contextType);
console.log(canvas.renderStrategy);
console.log(canvas.renderTarget+"\n");
drawLine(0,0,canvas.width,canvas.height,ctx);
}
}
}