2012-09-26 4 views
2
내가 QML의 웹보기

QML의 웹보기 페이지 로딩

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") 
     } 
    } 
} 

를 사용하여 로컬 페이지 (웹 OS 응용 프로그램)을 열려고

내가 MAIN.CPP이 방법으로로드 실패 이유를 찾는 방법 :

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(); 
} 

항상로드가 실패합니다. 문제를 발견 할 수있는 방법이 있습니까, 일부 웹 콘솔에서 실패한 것을 표시 할 수있게 할 수 있습니까?

감사

마르신 네트워크 오류 (도달 할 수없는 또는 잘못된 URL 등)에서 호출

답변

1

대부분의 경우 WebView::onLoadFailed.

시도해 볼 수있는 것은 NetworkAccessManager의 finished 신호를 수신하여 네트워크 응답에서 오류를 확인하는 것입니다. loggeronNetworkRequestFinished 슬롯이있는 QObject를하다

connect (viewer.engine()->networkAccessManager(), SIGNAL(finished(QNetworkReply*)), 
     logger, SLOT(onNetworkRequestFinished(QNetworkReply*))); 

.

void Logger::onNetworkRequestFinished(QNetworkReply* reply) 
{ 
    if (reply->error() != QNetworkReply::NoError) { 
     qDebug() << "network error:" << reply->errorString(); 
    } 
    reply->deleteLater(); 
} 

자세한 내용은 QNetworkReplydocumentation을 참조하십시오.