main.qml:
ApplicationWindow {
visible: true
visibility: "Maximized"
title: "My title"
WebView {
id: webView
objectName: "webView"
anchors.fill: parent
url: initialUrl
}
}
main.cpp中:
QQmlApplicationEngine engine;
QQmlContext *context = engine.rootContext();
context->setContextProperty(QString("initialUrl"), "http://google.com/");
QQmlComponent component(&engine, QUrl("qrc:/qml/main.qml"));
qDebug() << component.status();
component.create();
它适用于Linux和Android,但在Windows上我有这个错误:
warning: QQmlComponent::Status(Ready) // This "qDebug() << component.status();" from my code
warning: QQmlComponent: Component is not ready
warning: QObject::connect: invalid null parameter
warning: QObject::connect: invalid null parameter
warning: QObject::connect: invalid null parameter
warning: QObject::connect: invalid null parameter
Program received signal SIGSEGV, Segmentation fault.
0x6e9cd3dd in Qt5Quick!?setParentItem@QQuickItem@@QAEXPAV1@@Z () from C:\myprog-dist\Qt5Quick.dll
如何解决? Qt 5.7.0(msvc 2015编译器)
答案 0 :(得分:0)
解决方案:
请勿使用windeployqt。
为Windows安装Qt 5.7。 使用Process Explorer和手动复制依赖项。