I'm attempting to use the Canvas object in Qml. See code below.
When I run it using qmlscene, I get an error that says 'TypeError: object
is not a function' on the line in the Qml 'var img = new Image()'.
I think 'Image' is conflicting with the Qml Image object. If this is what
is happening, is there any suggested workaround for this problem?
import QtQuick 2.1
Canvas {
id: canvas
width: 600
height: 200
onPaint: {
var ctx = canvas.getContext('2d');
ctx.save();
ctx.clearRect(0, 0, canvas.width, canvas.height);
ctx.restore();
var img = new Image()
img.src = "https://www.google.com/images/srpr/logo4w.png"
img.onload = function() {
ctx.drawImage(img, 0, 0);
};
}
} // Canvas
_______________________________________________
Interest mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/interest