[Qt-interest] Invoke function in JavaScript

Joshua Lee muzili at gmail.com
Wed Dec 15 07:13:15 CET 2010


Hi No'am,
Here's an example,

QVariant TestApi::jsCall(const QString &function, const QVariant
user_data, const QVariant& new_data)
{
    QString script = QString( "%1.apply(this, %2)").arg(function).arg(user_data);
    return  webframe->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

-- 
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