[Qt-interest] Invoke function in JavaScript
noam.rosenthal at nokia.com
noam.rosenthal at nokia.com
Wed Dec 15 07:54:36 CET 2010
Ah, this thread was originally about QtScript, and this question is about the webkit JavaScript environment.
There's currently no way to do this within WebKit, the only way to pass values like this to Javascript is with properties, signals and slots, see
http://doc.qt.nokia.com/4.7/qtwebkit-bridge.html
No'am
On Dec 14, 2010, at 10:13 PM, ext Joshua Lee wrote:
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<mailto: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<mailto:mars.leezm at gmail.com>; qt-interest at trolltech.com<mailto: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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101215/ab51af8f/attachment.html
More information about the Qt-interest-old
mailing list