[Interest] Anti-aliasing for QML Canvas on Windows?

Mark markg85 at gmail.com
Fri Feb 15 19:49:15 CET 2013


Hi,

I'm drawing some shapes on Windows 7 with QML Canvas, but the output
really seems aliased as in the anti-aliasing is off.

The code:

import QtQuick 2.0

Item {
    width: 400
    height: 400

    Canvas {
        id:canvas
        width:400
        height:400
        antialiasing: true

        property string strokeStyle:"green"
        property string fillStyle:"yellow"
        property int lineWidth:10
        property bool fill:true
        property bool stroke:true


    onPaint: {
          var ctx = canvas.getContext('2d');
          ctx.save();
          ctx.clearRect(0, 0, canvas.width, canvas.height);
          ctx.strokeStyle = canvas.strokeStyle;
          ctx.fillStyle = canvas.fillStyle;
          ctx.lineWidth = canvas.lineWidth;

          ctx.arc(75,75,50,0,Math.PI*2,true); // Outer circle

          if (canvas.fill)
             ctx.fill();
          if (canvas.stroke)
             ctx.stroke();

          ctx.restore();
        }
    }
}

I'm using Qt 5.0.1 mingw build x86 on Windows 7.

Cheers,
Mark



More information about the Interest mailing list