blob: 6b10df752398c879640ffbcf7fb64add8d404b3b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Window
import QtWebEngine
//! [0]
QtObject {
id: windowParent
// Create the initial browsing windows and open the startup page.
Component.onCompleted: {
var firstWindow = windowComponent.createObject(windowParent);
firstWindow.webView.loadHtml('<input type="button" value="Click!" onclick="window.open("http://qt.io")">');
}
property Component windowComponent: Window {
// Destroy on close to release the Window's QML resources.
// Because it was created with a parent, it won't be garbage-collected.
onClosing: destroy()
visible: true
property WebEngineView webView: webView_
WebEngineView {
id: webView_
anchors.fill: parent
// Handle the signal. Dynamically create the window and
// use its WebEngineView as the destination of our request.
onNewWindowRequested: function(request) {
var newWindow = windowComponent.createObject(windowParent);
newWindow.webView.acceptAsNewWindow(request);
}
}
}
}
//! [0]
|