[Android-development] Look of widgets on Android

Rutledge Shawn Shawn.Rutledge at theqtcompany.com
Mon Dec 29 08:43:41 CET 2014


On 26 Dec 2014, at 13:53, A. Savelov <s_savelov at mail.ru> wrote:

> Hello!
> 
> It seems that canvasWindow doesn't change its position or I'm doing smth wrong.
> This is my qml code, whick draws line from (0,0) position instead of (200,0)
> 
> import QtQuick 2.4
> import QtQuick.Window 2.2
> 
> Window {
>     visible: true
> 
>     Canvas {
>         id: canvas
>         canvasSize: "1000x1000"
>         tileSize: "100x100"
>         canvasWindow: Qt.rect(200,0,300,300);
> 
>         onPaint: {
>             var ctx = getContext("2d");
>             ctx.save();
> 
>             ctx.strokeStyle = "red";
>             ctx.lineWidth = 20;
> 
>             // ![0]
>             ctx.beginPath();
>             ctx.moveTo(0,0);
>             ctx.lineTo(1000,1000);
>             ctx.closePath();
>             ctx.stroke();
>             // ![0]
> 
>             ctx.restore();
>         }
>     }
> }

That is not specific to Android.  It doesn’t seem like correct behavior to me; not sure.  You expected it to clip off the left 200 pixels, right?  But it’s the same on desktop platforms.  Setting clip: true doesn’t make a difference.  All the autotests in qtdeclarative/tests/auto/quick/qquickcanvasitem are passing though, and some of them are testing canvasWindow.

If you wanted to offset it, you can of course set the x and y since it’s an Item.


More information about the Android-development mailing list