PDA

View Full Version : QWebView XMLHttpRequest performance



theH
22nd September 2012, 13:25
Hello,

I have created a simple Qt application with a webview and let it load a url:


webView = new QWebView(this);
setCentralWidget(webView);
webView->load(QUrl("http://localhost:8080/responsetest.html"));

This loads a html page which uses XMLHttpRequest and displays the time it took to load it:


<html>
<body>
<script>
var num = 0;

function mouseClicked()
{
num++;
var time = new Date().getTime();

var xmlhttp = new XMLHttpRequest();

xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
time = new Date().getTime() - time;
document.getElementById('link').innerHTML = "Response "+num+" took "+time+"ms.";
}
}
xmlhttp.open("GET", "responsetest.html?q="+time, true);
xmlhttp.send();
}
</script>
<div><a onclick="mouseClicked()" id="link" href="#" >click me</a></div>
</body>
</html>

The thing is, it takes more than a second to load whereas other browsers need 7 milliseconds!

Actually, my local server (mongoose) shows, that Qt is waiting one second before it is even attempting the request. Is that at all possible? And how could I fix it?

I found out that even Safari shows this behaviour but Chrome and Firefox don't. What could be behind this?

Cheers!