[Interest] [QML][QWebView] access QML function from html/javascript context

Christoph Petzold christoph.petzold at hasomed.de
Thu Jul 9 11:21:02 CEST 2015


how do i acces a custom QML function from within the HTML/JavaScript of a loaded web page.

I managed to do it with the QWidget variant:

QWebFrame* webframe = webView_->page()->currentFrame();

javaScriptBridge_ = new JavaScriptBridge;

webframe->addToJavaScriptWindowObject("cppObject", javaScriptBridge_);

With this i was able to call 

function sayHello(text)




from the HTML/JavaScript context of the loaded html-file of the webframe.

I am looking for a way to do the same for the QWebView or QWebengineView QML component.




id: webEngineView

                url: »index.html«

                function fromWebcontentToQML(text)





So how to call fromWebcontentToQML from within index.html?

Mit freundlichen Grüßen/ Best regards

Christoph Petzold

Mitarbeiter Abteilung Funktionelle Elektrostimulation


Paul-Ecke-Str. 1
39114 Magdeburg

Tel.: +49 391  62 30 112

Fax: +49 391  62 30 113

E Mail: christoph.petzold at hasomed.de <mailto:christoph.petzold at hasomed.de> 

Web: www.hasomed.de <http://www.hasomed.de/> 

HRB 108418
UST IdNo DE 114 161 708
Steuernummer 102/111/09705
GF Dr. Peter Weber, Frank Schulze

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150709/35fde2e8/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/png
Size: 4549 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20150709/35fde2e8/attachment.png>

More information about the Interest mailing list