QML WebView 组件尚未准备就绪

QML WebView component is not ready

本文关键字:准备就绪 组件 WebView QML      更新时间:2023-10-16

main.qml:

ApplicationWindow {
  visible: true
  visibility: "Maximized"
  title: "My title"
  WebView {
    id: webView
    objectName: "webView"
    anchors.fill: parent
    url: initialUrl
  }
}

主.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-distQt5Quick.dll

如何解决?Qt 5.7.0 (msvc 2015 编译器(

解决方案:

不要使用 windeployqt。

安装 Qt 5.7 for Windows。使用进程资源管理器和手动复制依赖项。