@jsulm has already given the right answer.
In case anyone arrives at this page and has a similar question but using QML, here is an example of handing the signal in QML:
WebEngineView {
id: thisWeb
anchors.fill: parent
url: dlViewModel.targetUrl
onNewViewRequested: function (request) {
// Any user can trigger newViewRequested by simply holding the CTRL key while clicking any hyperlink.
// This forces any attempt at opening a new browser "tab" to open in this one instead:
// (tested using qt 5.15 on Linux)
// (refer to: https://doc.qt.io/qt-5/qml-qtwebengine-webengineview.html#newViewRequested-signal)
request.openIn(thisWeb)
}
}
The following is also a good resource:
https://doc.qt.io/qt-5/qtwebengine-webenginewidgets-simplebrowser-example.html
^^ That example uses C++, so it is relevant to @nammi98
↧