In code below I have WebEngineView and keys are handled in two ways - in second case, from dynamically loaded component.
Key handler does not work, in dynamically loaded component, when I am using WebEngineView.
web.qml
import QtQuick 2.0
import QtWebEngine 1.2
Item{
id: root
height: 500
width: 500
WebEngineView {
id: manualWebView
height: 500
width: 500
enabled: true
url: "https://www.google.com/"
}
Keys.onReleased: {
console.log("Loaded item captured INSIDE:",
event.text);
}
Loader {
id: loader
source: "debug.qml"
focus: true
onStatusChanged: {
if (loader.status == Loader.Ready) console.log('Loaded')
else
console.log("Status changed: "+loader.status )
}
}
}
import QtQuick 2.0
import QtWebEngine 1.2
Item{
id: root
height: 500
width: 500
WebEngineView {
id: manualWebView
height: 500
width: 500
enabled: true
url: "https://www.google.com/"
}
Keys.onReleased: {
console.log("Loaded item captured INSIDE:",
event.text);
}
Loader {
id: loader
source: "debug.qml"
focus: true
onStatusChanged: {
if (loader.status == Loader.Ready) console.log('Loaded')
else
console.log("Status changed: "+loader.status )
}
}
}
To copy to clipboard, switch view to plain text mode
debug.qml
import QtQuick 2.0
Item {
focus:true
Keys.onReleased: {
console.log("Loaded item captured OUTSIDE:",
event.text);
}
}
import QtQuick 2.0
Item {
focus:true
Keys.onReleased: {
console.log("Loaded item captured OUTSIDE:",
event.text);
}
}
To copy to clipboard, switch view to plain text mode
and output is:
$ qmlscene web.qml
qml: Loaded
qml: Loaded item captured INSIDE: q
qml: Loaded item captured INSIDE: t
$ qmlscene web.qml
qml: Loaded
qml: Loaded item captured INSIDE: q
qml: Loaded item captured INSIDE: t
To copy to clipboard, switch view to plain text mode
Second handler(from loader) works properly when I remove WebEngineView.
Output after removing WebEngineView:
$ qmlscene web.qml
qml: Loaded
qml: Loaded item captured OUTSIDE: q
qml: Loaded item captured INSIDE: q
qml: Loaded item captured OUTSIDE: t
qml: Loaded item captured INSIDE: t
$ qmlscene web.qml
qml: Loaded
qml: Loaded item captured OUTSIDE: q
qml: Loaded item captured INSIDE: q
qml: Loaded item captured OUTSIDE: t
qml: Loaded item captured INSIDE: t
To copy to clipboard, switch view to plain text mode
Why key handling does not work in dynamically loaded component when I am using WebEngineView ?
How can I solve it ?
Bookmarks