1

In Qt Creator I see "HTML5 Application" wizard. It creates a project with "html5applicationviewer" sub-project that loads the HTML and injects the object named "Qt" object with only public slot "quit" (which is used in the demo code).

If I change html5applicationviewer to also inject my object in addition to "Qt", it Qt Creator suggests to "upgrade" html5applicationviewer; and there's a comment This file was generated ... It is recommended not to modify this file in html5applicationviewer's files.

How to properly add more Qt C++ things to the HTML part in Qt HTML5 applications?

1 Answer 1

2

To my knowledge there are two ways you can extend your Qt HTML5 application. The first one is indeed by injecting your QObjects to make them visible in JavaScript. This you do in response to javaScriptWindowObjectCleared() signal emitted by web view page main frame.

The second way is to provide custom plugin factory to the web view page (see QWebPage::setPluginFactory() method). This way allows you creating Qt objects (e.g. widgets) instances directly in HTML code (using <object> tag).

Sign up to request clarification or add additional context in comments.

Comments

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.