bpetty
13th May 2008, 17:25
I am adding html/js to my QWebView like so... and I am also adding my custom object like so... but I can't get the object to do anything inside of the javascript.
uiDemo.webView->setHtml(sCode.toUtf8());
uiDemo.webView->page()->mainFrame()->addToJavaScriptWindowObject("QtJSObject", m_pJSObj);
// The javascript code that doesn't run
window.alert('QtJSObject.var is:' + QtJSObject.var)
// My object properites
Q_PROPERTY(int var READ getVar WRITE setVar);
When I ask for the value of "var" from the properties method in C++ it returns fine... just not in my script. Am I adding the JavaScript Object to my QWebView correctly?
uiDemo.webView->setHtml(sCode.toUtf8());
uiDemo.webView->page()->mainFrame()->addToJavaScriptWindowObject("QtJSObject", m_pJSObj);
// The javascript code that doesn't run
window.alert('QtJSObject.var is:' + QtJSObject.var)
// My object properites
Q_PROPERTY(int var READ getVar WRITE setVar);
When I ask for the value of "var" from the properties method in C++ it returns fine... just not in my script. Am I adding the JavaScript Object to my QWebView correctly?