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);
uiDemo.webView->setHtml(sCode.toUtf8());
uiDemo.webView->page()->mainFrame()->addToJavaScriptWindowObject("QtJSObject", m_pJSObj);
To copy to clipboard, switch view to plain text mode
// 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);
// 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);
To copy to clipboard, switch view to plain text mode
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?
Bookmarks