1

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.

1 Answer 1

2

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);
Sign up to request clarification or add additional context in comments.

1 Comment

That was really useful but finally I created several functions in my html file with JavaScript and call them using evaluateJavaScript(). I found it more useful. Something like QString cmd("MyFunction();"); view->page()->mainFrame()->evaluateJavaScript(cmd);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.