我尝试使用 QML WebView 打开本地页面(WebOS 应用程序)
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")
}
}
}
我以这种方式将它加载到 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();
}
我总是加载失败。有什么办法可以找出问题,启用一些 Web 控制台来告诉我什么是失败的。
谢谢
马尔钦