PDA

View Full Version : Why my webview does not load page at QML start?!?



Szyk
2nd March 2017, 20:24
Hi
My Qml page is very simple: ToolButton and WebView. Now it loads background and shows nothing but white rectangle (WebView object) even toolbutton is transparent, but accessible. I can load page by hand (clicking on toolbutton). But I want open page at application start! My code is as follow:

import QtQuick 2.2
import QtQuick.Controls 1.4
import QtWebView 1.1
import QtQuick.Layouts 1.1

Rectangle {
id: rec1
color: "black"
gradient: Gradient {
GradientStop {
position: 0.00;
color: "#000000";
}
GradientStop {
position: 1.00;
color: "#ffffff";
}
}

ToolButton {
id: reloadButton
tooltip: qsTr("Reload")
onClicked: web1.url = "http://google.pl"
}


// anchors.fill: parent
WebView {
id: web1
objectName: "web1"
visible: true
anchors.top: reloadButton.bottom
anchors.bottom: parent.bottom
anchors.left: parent.left
anchors.right: parent.right
//anchors.fill: parent
anchors.margins: 10
url: "http://google.pl"
onLoadingChanged: {
if(loadRequest.errorString)
console.error(loadRequest.errorString);
else
console.info("Load web page successfull");
}
Component.onCompleted: function() { web1.url = "http://google.pl"; web1.reload(); console.info("Load successfull"); }
}
}


How to load web page just after application start?!?

thanks and best regards
Szyk Cech

anda_skoa
3rd March 2017, 12:54
Works for me, with and without the Component.onCompleted.

Qt 5.8 on Linux

Cheers,
_

Szyk
4th March 2017, 14:16
I try it with Qt 5.6.2 on Windows 10. So maybe it is some already fixed bug...