4
votes

I know it is possible to do this with the deprecated class QtWebkit as shown here.

I would like to know if similar work can be done with the new QtWebEngine framework? I could not find a method to create plugin in a web page (QWebEnginePage). Is this related to the plugin technology in Chromium?

I'm currently just exploring the possibility of achieving this with Qt 5.5.

2
I don't think it's possible (same reasoning as Nicholas Smith), but maybe you could consider one of these alternatives: (a) QML is quite close to HTML, maybe use QML instead? (b) You can expose a Qt object to the web page and interact with it through Javascript. You'd have to paint the widget in JS then.Georg Schölly
Thank you too, Georg! The 2nd option you gave is interesting. But I think I have no luck in this case use many existing QWidgets we have developed. I'd like to serve an existing GUI to the remote user using a browser. HTML5 is of course a good alternative but it needs new development on the client side.Ting
If your widgets are non-interactive, you could paint them off-screen and expose them as an image to the web engine.Georg Schölly

2 Answers

4
votes

I can't find a completely clear answer one way or another, however at the end of the porting guide there's something that would suggest it's no longer possible:

Qt WebEngine renders web pages using Skia and is not using QPainter or Qt for this purpose. The HTML5 standard also now offers much better alternatives that were not available when native controls plugins were introduced in Qt WebKit.

No QPainter would mean that there's no way to draw a QWidget during render.

0
votes

Instead of embedding a QWidget in a QWebEngineView, you can have a QWidget as the child of a QWebEngineView. You may need to fiddle a bit with positions, transparency, and/or stacking order but it is doable. You can coordinate between the QWebEngineView and the native Qt code using a QWebChannel.

I have this working tolerably well on DomTerm (hhtps::/github.com/PerBothner/DomTerm). DomTerm is a rather complicated (partly because it supports lots of configurations including running on other frameworks besides Qt and using iframes instead QWidgets). However, handling the "embedded" QWidgets is relatively simple. If there is interest I can explain more how it works, and the most relevant sections of the code.