[Interest] Using Qml canvas object (name conflict with Image?)
Alan Alpert
416365416c at gmail.com
Wed Sep 11 22:51:22 CEST 2013
I wouldn't expect that to happen, but if that is indeed the issue then
there is a simple workaround.
import QtQuick 2.0 as QQ
QQ.Canvas {
[....]
}
--
Alan Alpert
On Wed, Sep 11, 2013 at 12:42 PM, Chris Meyer <cmeyer1969+qt at gmail.com> wrote:
> 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
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
More information about the Interest
mailing list