Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is Possible To Add WebView or WebEngine To QmlWeb? #460

Open
titus-shoats opened this issue Oct 9, 2022 · 1 comment
Open

Is Possible To Add WebView or WebEngine To QmlWeb? #460

titus-shoats opened this issue Oct 9, 2022 · 1 comment

Comments

@titus-shoats
Copy link

Hello quick question is it possible to add WebView or WebEngine?. Can anyone give me any advice on how one would go about doing this, or even if its possible? Thanks

@Plaristote
Copy link
Member

It's something I've looked into in the past, and I believe the short answer was : nope !

But there's a long answer.

There's already an implementation of WebView in qmlweb (use import QtWebView 1.0). It uses an iframe to provide a result similar to the native WebView... but some features are unavailable: history, loading html directly into the iframe, managing cookies...

These are things that we just can't do reliably with iframes, mostly because of the default CORS setup, which will prevent you from running JavaScript within an iframe... which you'd definitely need to do stuff like injecting HTML, managing the history, etc.

If you're interested in this topic, the following discussion on stackoverflow will give you all the details you need:
https://stackoverflow.com/questions/251420/invoking-javascript-code-in-an-iframe-from-the-parent-page

Basically, and if memory serves well : assuming you use the WebView to display a page that's hosted on a server that you own, then you could configure it to allow your QMLWeb application to run JavaScript inside the iframe. An implementation of WebView within QMLWeb could work on these conditions.

Here's the current implementation for WebView:
https://github.com/qmlweb/qmlweb/blob/master/src/modules/QtWebView/WebView.js

The same argument can be made for WebEngine... there's probably a whole bunch of stuff in WebEngine that just cannot be done through JavaScript code that would run from within a browser.

Anyhow, if you're interested in trying to provide a better WebView implementation, I can provide some guidance... but I'm a bit too busy at the moment to tackle this right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants