Rella
Rella

Reputation: 66995

C++, Qt, QtWebKit: How to create an html rendering window so that your application would get callbacks from JS calls?

What I need is simple: we have a console app project. We want to have such a function that would open a simple window with nothing but html QtWebKit html+js rendering window that would read some default html+js string (form string or const char*). we want to have our own api joined with default js api so that when JS calls some our.function(argument); we would have our C++ application performe some function and for example cout argument. How to create such thing using Qt?

PS: this question is related to my previous one , I just suddenly got Idea that doing it once for all platforms would be much better.

Upvotes: 2

Views: 969

Answers (1)

Fred
Fred

Reputation: 4954

Have a look at QWebFrame::addToJavaScriptWindowObject(). It lets you expose a C++ QObject to the javascript in your page. Your html+js can then call C++ methods on that object from the web page.

Upvotes: 1

Related Questions