[Qt-interest] JavaScript persistent execution context?

noam.rosenthal at nokia.com noam.rosenthal at nokia.com
Sun Oct 10 10:18:35 CEST 2010


Hello Sherzod

Is this in QWebFrame or in QtScript? Do you actually have a web-page? How do you currently initialize your context? Can you post some initialization C++ code here?

In general I'm guessing that the answer to your problem would be to add those functions to a global object, e.g. in webkit:
instead of

function wakeUp() { ... }

write

window.wakeUp = function() { ... };

But I'm not sure I'm answering the right question...

No'am

________________________________________
From: qt-interest-bounces at trolltech.com [qt-interest-bounces at trolltech.com] On Behalf Of ext sherzod_ [sherzod.l at mail.ru]
Sent: Wednesday, October 06, 2010 9:11 AM
To: qt-interest at trolltech.com
Subject: [Qt-interest] JavaScript persistent execution context?

Hello.

How do I create persistent JavaScript execution context. For example I
connect a function defined in JS code to a qt c++ signal. I need this
function to be called even after running out the JS code.

In other words i need a signal-slot connection created in a script to stay
alive after leaving script context, and surely clear this context maybe
manually later.

// --------------------------------------------------
        c++
// --------------------------------------------------
...

SomeQtObject: public QObject
{
        ...

        signals:
                void jingleJingle();

        ...
};


// --------------------------------------------------
        javascript
// --------------------------------------------------

...

function wakeUp()
{
        alert("wake up!");
}

function run()
{
        // SomeQtObject injected as myObj

        myObj.jingleJingle.connect(wakeUp);
        // need this connection after quitting this code
}

run();

// --------------------------------------------------

Thanks.

ps. QWebFrame is the example of such behaviour. Web pages script context is
persistent during livetime of it.

_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list