[Qt-interest] Invoke function in JavaScript

Joshua Lee muzili at gmail.com
Wed Dec 15 10:12:05 CET 2010


Hi Gopalakrishna,
I would like to export Qt TestApi object to javascript, because some of
the methods takes long time and can not response instantly. So the
best way is using async way that Qt push the results to javascript
when it finish the operation.


Best regards,
Joshua

On Wed, 15 Dec 2010, Gopalakrishna Bhat wrote:

> Hi,
> 
> What do you mean by putting new_data into the function? If I
> understand it right, you can pass new_data as a parameter to apply.
> 
> With regards,
> Gopalakrishna Bhat
> 
> 
> 
> On Wed, Dec 15, 2010 at 11:43 AM, Joshua Lee <muzili at gmail.com> wrote:
> > Hi No'am,
> > Here's an example,
> >
> > QVariant TestApi::jsCall(const QString &function, const QVariant
> > user_data, const QVariant& new_data)
> > {
> > ? 燪String script = QString( "%1.apply(this, %2)").arg(function).arg(user_data);
> > ? 爎eturn 爓ebframe->evaluateJavaScript(script);
> > }
> >
> > How can i put the new_data into the function?
> >
> > Thanks.
> >
> >
> > Best regards,
> > Joshua
> >
> > On Wed, 15 Dec 2010, noam.rosenthal at nokia.com wrote:
> >
> >> >-----Original Message-----
> >> >From: ext Joshua Lee [mailto:muzili at gmail.com]
> >> >Sent: Tuesday, December 14, 2010 7:56 PM
> >> >To: Rosenthal Noam (Nokia-MS-Qt/RedwoodCity)
> >> >Cc: mars.leezm at gmail.com; qt-interest at trolltech.com
> >> >Subject: Re: [Qt-interest] Invoke function in JavaScript
> >> >
> >> >Hi No'am,
> >> >I want pass C++ value to javascript function 'foobar',
> >> >how to get it?
> >> >
> >> You convert it into a QScriptValue, e.g. by wrapping it in a QVariant (http://doc.trolltech.com/4.7/qscriptengine.html#newVariant)
> >>
> >> I suggest some light reading: http://doc.trolltech.com/4.7/scripting.html
> >> It's all there :)
> >>
> >> No'am
> >
> >
> > TEL: (86-21)61609650 EXT: 8020
> > FAX: (86-21)61609650 EXT: 8041
> > ADD: Suite 301, No.10, 198 Lane, Zhangheng Road,
> > ? ? ZJ Hi-Tech Park, Shanghai, China 201204
> >
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
> >
> 
> 
> 

-- 
Joshua Lee
Alpha Networks(Chengdu) Co., LTD
Shanghai Branch

TEL: (86-21)61609650 EXT: 8020
FAX: (86-21)61609650 EXT: 8041
ADD: Suite 301, No.10, 198 Lane, Zhangheng Road,
     ZJ Hi-Tech Park, Shanghai, China 201204





More information about the Qt-interest-old mailing list