[Qtwebengine] new QML window API
Simon Hausmann
simon.hausmann at digia.com
Wed Jan 22 15:04:15 CET 2014
On Friday 3. January 2014 11.43.07 Simon Hausmann wrote:
[...]
Finally this idea didn't pan out because the component hierarchy wouldn't
support this if the webview component was inside a loader but declared
elsewhere, as pointed out by Jocelyn.
So after a brief discussion with Jens and Gabriel I'd now also like to
request (partial) membership in the party that advocates the imperative
API ;-).
Summary of suggestion by code:
TabView {
id: tabView
Component {
id: webViewComponent
WebView {
newWebViewComponent: webViewComponent
// invisible "view" parameter, the newly created view that has no visual parent
onViewCreated: {
if (view.url == "http://i-want-to-block-this.com/") {
view.parent = null; // Not needed, but more readable that way. The calling webview will delete a view again if it has no visual parent after signal emission
return;
}
if (wantItInAWindow) {
... add it to a window
} else {
tabView.addTab(view); // They'll add support for item based insertion to controls :)
}
}
}
}
An alternative to "magic" rejection on the signal handler for implementing popup blocking for example would be
the use of an attached property perhaps:
onViewCreated: {
if (view.url = "bad") {
WebView.rejectView = true;
return;
}
Or perhaps this should be consistent with events?
onViewCreated: {
if (view.url == "bad") {
view.accept = false; (or reject = true or both?)
return
}
Thoughts? :)
Simon
More information about the QtWebEngine
mailing list