user3770060
user3770060

Reputation: 115

Send data to a html website embeded in QT gui using Qwebview

I am working on a desktop application in QT (c++). It embeds a website I created with a simple html file (includes javascript) using Qwebview. The website contents a plugin and some html boxes. The data in those boxes makes a change in the pluguin.

My intention is to send data to that html code from my QT code in a way the user won't have to manipulate directly the plugin. My only experience wit QT and html is this project so I am not sure how I should proceed.

I did some research and apparently jquery could be a solution. It would be ideal to send the information in variables directly to the plugin instead of filling html boxes, however I think it is not possible.

My apologies if I haven't used the right technical vocabulary to describe my situation but I am a beginner with those technologies.

Upvotes: 1

Views: 335

Answers (1)

Silas Parker
Silas Parker

Reputation: 8147

To do this you need to use the QWebFrame::evaluateJavaScript function to run a bit of JavaScript (JS) in the page. Most plugins can be scripted using JS, so you just need to write snippets of JS to trigger the functions.

QWebView* view;
// ...
QString cmd("document.getElementById(\"pluginid\").myPluginFunction();");
view->page()->mainFrame()->evaluateJavaScript(cmd);

Upvotes: 2

Related Questions