[Interest] Using Qml canvas object (name conflict with Image?)
Chris Meyer
cmeyer1969+qt at gmail.com
Wed Sep 11 21:42:24 CEST 2013
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20130911/fffb6194/attachment.html>
More information about the Interest
mailing list