Reputation: 6414
I try to open a local page (WebOS app) using QML WebView
import QtQuick 1.1
import QtWebKit 1.0
import com.nokia.meego 1.0
Page
{
id: mainPage
Flickable
{
id: appFlickable
anchors.fill: parent
clip: true
contentHeight: appView.height
contentWidth: appView.width
WebView
{
id: appView
preferredHeight: parent.height
preferredWidth: parent.width
url: appUrl
settings.javascriptCanOpenWindows: true
settings.javascriptEnabled: true
settings.autoLoadImages: true
settings.javascriptCanAccessClipboard: true
settings.developerExtrasEnabled: true
onLoadFailed: console.log("load failed")
onLoadFinished: console.log("load finished")
}
}
}
I load it in main.cpp this way:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QDeclarativeView view;
view.rootContext()->setContextProperty("appUrl", argv[1]);
view.setSource(QUrl("qrc:/qml/main.qml"));
view.showFullScreen();
return app.exec();
}
I'm always getting a load fail. Is there any way I can find out the problem, enable some web console to show me what fails.
Thanks
Marcin
Upvotes: 2
Views: 1561
Reputation: 3631
Most likely WebView::onLoadFailed
called on network errors (unreachable or invalid url etc.).
What you can try to do, is to listen to NetworkAccessManager's finished
signal to check network reply for error.
connect (viewer.engine()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)),
logger, SLOT(onNetworkRequestFinished(QNetworkReply*)));
Where logger
is a QObject with onNetworkRequestFinished
slot.
void Logger::onNetworkRequestFinished(QNetworkReply* reply)
{
if (reply->error() != QNetworkReply::NoError) {
qDebug() << "network error:" << reply->errorString();
}
reply->deleteLater();
}
For details refer to QNetworkReply
documentation.
Upvotes: 1