QML使用webkit載入網頁報錯解決方法 qml: Error creating SSL context ()
阿新 • • 發佈:2018-12-07
折騰了三天!!!!!
QT簡直是太坑爹了!!!!!!
QML載入網頁,用webkit,webview總是載入不出來網頁!!!!!!
最後列印了錯誤,發現是SSL不對,看網上好多人說要重新安裝OPENSSL,好複雜好複雜,最後發現就是QT執行時候缺少了兩個dll!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
我去,而且這兩個庫是Qt自帶的!路徑是:D:\Qt\Qt5.4.2\Tools\mingw491_32\opt\bin,libeay32.dll和ssleay32.dll給你跪了!!!!!,把這兩個檔案拷貝出來,考到D:\Qt\Qt5.4.2\5.4\mingw491_32\bin,再執行就沒有報錯了!
https://my.oschina.net/chrisforbt/blog/521650?fromerr=cgRbaELN
按這裡說的做,網頁載入成功!
import QtQuick 2.0
import QtQuick.Controls 1.0
import QtWebKit 3.0
ScrollView {
width: 1280
height: 720
WebView {
id: webview
url: "http://www.baidu.com"
anchors.fill: parent
onNavigationRequested:
{
// detect URL scheme prefix, most likely an external link
var schemaRE = /^\w+:/;
if (schemaRE.test(request.url)) {
request.action = WebView.AcceptRequest;
} else {
request.action = WebView.IgnoreRequest;
// delegate request.url here
}
}
onLoadingChanged: {
console.log(loadRequest.errorCode);
console.log(loadRequest.errorString);
console.log(loadRequest.errorDomain);
}
}
}