[Qt-interest] Qt vs Adobe Flash etc

Stephen Kelly steveire at gmail.com
Thu Oct 15 20:51:37 CEST 2009


Jason H wrote:

> I tried that a few months ago, and no, it did not work. Hence my epic
> disappointment, and my switch to PyQt. I would love to see it work, and
> that is why I am carring on this thread - because I want it to work!! I
> want to be told I was wrong!

I tried this too, and it didn't work for me either. I did come up with a
workaround, but I'm not especially happy with it so I'll try again for a new
one when I have the time.

I wanted to implement the Node and Filter classes here in QtScript:

http://gitorious.org/grantlee/grantlee/blobs/master/grantlee_core_library/filter.h
http://gitorious.org/grantlee/grantlee/blobs/master/grantlee_core_library/node.h

I ended up creating C++ classes to wrap the qtscript implementation:

http://gitorious.org/grantlee/grantlee/blobs/master/grantlee_scriptabletags/scriptablefilter.h
http://gitorious.org/grantlee/grantlee/blobs/master/grantlee_scriptabletags/scriptablenode.h

And then using a factory to create nodes of types defined in script:

http://gitorious.org/grantlee/grantlee/blobs/master/grantlee_scriptabletags/scripteddefaults.qs
http://gitorious.org/grantlee/grantlee/blobs/master/tests/testtags.qs

See for example

var node = new Node("EchoNode", content);

where Node is the ScriptableNode above.

I don't think it's the best solution available, but it does work.


All the best,

Steve.


>
> Hmm, so this doesn't work?
>
> function AffineText(text,font) {
>         this.path = QPainterPath();
>         this.path.addText( text, 0, QFontMetrics(font).ascent(), font);
>
>     function boundingRect() {
>         return this.path.boundingRect();
>     }
>
>     function paint(painter,option,widget) {
>         painter.paint(this.path);
>     }
> }
>
> AffineText.prototype = new QGraphicsItem();
>
> mytext = new AffineText("foobar",QFont("somefont"));
>
> Just from the top of my head, how it should work with JS code. I mean
> without this a general purpose script binding is rather useless...
>
> Andreas
>



More information about the Qt-interest-old mailing list