[Qt-interest] Qt vs Adobe Flash etc

Andreas Pakulat apaku at gmx.de
Tue Oct 13 21:36:41 CEST 2009


On 13.10.09 11:31:41, Jason H wrote:
> Oh, that still is not what I am talking about. 
> 
> You still need C++ code to make those classes available in Script land.
> 
> In PyQt, I can:
> class AffineText(QGraphicsItem):
>     def __init__(self, text, font):
>         self.path=QPainterPath()
>             fm=QFontMetrics(font)
>             self.path.addText(text, 0, fm.ascent(), font)
> 
>        def boundingRect():
>          return self.path.boundingRect()
> 
>      def paint(painter, option, widget):
>          painter.paint(self.path)
> 
> 
> then the C++ QPainter will still be able to draw the Python-defined object
> 
> Let's see QtScript define a new class like that, without any C++ coding! My point was, and still seems to be, you can't. I tried the same approach in QtScript, but QtScript was never able to use the derived object for anything. It is just not acceptable to have to recompile code every time. Even if you seperate it out in a plugin, you then introduce platform dependencies. If you are going o replace flash, the "compile anywhere" idiom doesn't work. However doing it in Python allows the same byte code to be used on every platform, meaning your QtFlash app won't care about your platform. beyond the compilation of the browser plugin. 
> 
> Unless I am still missing something...? 

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

-- 
Fine day to work off excess energy.  Steal something heavy.



More information about the Qt-interest-old mailing list