[wpe-webkit] QML WPEView dynamic loading
Gregor Felzer
gregor.felzer at gmail.com
Fri Mar 12 00:48:47 PST 2021
Hi,
I'm evaluating WPEQt a bit and have an issue with WPEView control. When a
component which includes WPEView is dynamically created, WPEView is not
loaded and nothing is shown.
Example 1 - WPEView is used in the root QML file, all is ok.
/// main.qml ///
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import org.wpewebkit.qtwpe 1.0
Window {
width: 640
height: 480
title: qsTr("WPEQt Demo")
visible: true
Rectangle {
id: rect1
anchors.top: button1.bottom
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
color: "grey"
Rectangle {
x: 10
y: 10
width: 620
height: 410
color:"lightblue"
WPEView {
anchors.fill: parent
url: "https://www.google.com/"
}
}
}
}
Example 2 - loaded dynamically (WPEView in MyRect which is loaded on button
press), WPEView is not shown.
/// main.qml ///
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
Window {
width: 640
height: 480
title: qsTr("WPEQt Demo")
visible: true
property var myrect
Button {
id: button1
text: qsTr("Button 1")
width: parent.width / 2
height: 0.1 * parent.height
anchors.top: parent.top
anchors.left: parent.left
onClicked: {
console.log("button1 clicked")
var component = Qt.createComponent("MyRect.qml");
myrect = component.createObject(rect1);
}
}
Button {
id: button2
text: qsTr("Button 2")
width: parent.width / 2
height: 0.1 * parent.height
anchors.top: parent.top
anchors.right: parent.right
onClicked: {
console.log("button2 clicked")
myrect.destroy(10);
}
}
Rectangle {
id: rect1
anchors.top: button1.bottom
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
color: "grey"
}
}
/// MyRect.qml ///
import QtQuick 2.15
import org.wpewebkit.qtwpe 1.0
Item {
id: myrectitem
Rectangle {
x: 10
y: 10
width: 620
height: 410
color:"lightblue"
WPEView {
anchors.fill: parent
url: "https://www.google.com/"
}
}
}
Appreciate any answers or ideas on what to try out. Thanks.
Gregor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-wpe/attachments/20210312/73b60809/attachment.htm>
More information about the webkit-wpe
mailing list