1

I am looking to rewrite a Qt application in HTML, and have QtWebEngine to render it for me. I fully understand that a HTML page will display and run in QtWebEngine.

However, one thing I am really interested in, and am unable to find documentation on - apologies if I'm looking in the wrong places - is to know if QtWebEngine allows for elements of the DOM to be "swapped" for native Qt widgets. For example, could a <div id="myWidget"> actually be a QOpenGLWidget? Is this completely nonsensical?

e.g I'd love to be able to do:

<body>
<h1>Example</h1>
<div id="myWidget">
</div>
<p>Some text</p>
</body>

and magically have my QOpenGLWidget rendered in the DOM in the place of "myWidget". My HTML could only ever be rendered by QtWebEngine, not necessarily by other browsers, so if there is a solution that means it wouldn't work in Chrome/Firefox/IE that is absolutely fine with me.

...Or would I have to use javascript running in the QtWebEngine instance to find out the position of "myWidget" and draw the QOpenGLWidget pixel data in that position myself? I really don't want to go down this route as it does not allow for things like HTML dialogs over the top of "myWidget".

I'd really appreciate any info here. An example (if this is even possible) would be fantastic. Many thanks in advance.

1 Answer 1

3

Solution for QtWebKit:

You will need to subclass QWebPluginFactory and create your widget in its create method. Then you could embed your widgets in HTML with <object> tag:

<object type="application/x-qt-plugin" name="myWdget" classid="QOpenGLWidget">
</object>

See example here

And another example here

...seems not valid anymore for new QtWebEngine.

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

3 Comments

Thanks Archie! It unfortunately looks like these are not compatible with QtWebEngine - see "Unavailable Qt WebKit APIs" here: qt-project.org/wiki/…
Oh, right, my bad. New QtWebEngine has quite limited extensibility comparing to WebKit. Is it possible for you to switch back using QtWebKit?
I'll certainly experiment - thank you so much for your answer. It's at least highlighted what I'm after is possible with Qt.

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.