qtwebengineqt5.7qtwebchannel

QWebChannel: crash on construction when running outside of QtCreator


When I try to run my programm outside the QtCreator, the code crashes, when new QWebChannel(this) is called. I already checked DLL dependencies, but can't find the difference between running it from within the IDE and outside of it.

MyView::MyView() : ui(new Ui::MyView) {
    ui->setupUi(this);
    view = new QWebEngineView(this);

    channel = new QWebChannel(this); // crash at this line

    ui->content->addWidget(view);
    connect(view, &QWebEngineView::loadFinished, this, &MyView::finishLoading);
    view->page()->setWebChannel(channel);
    channel->registerObject("controller", this);
    view->load(QUrl("qrc:///res/index.html"));
}

In the project file I added QT += webengine webenginewidgets webchannel. Are there any other dependencies I may forgot?


Solution

  • Running windeployqt.exe copies all necessary dependencies (see https://doc.qt.io/qt-5/windows-deployment.html). Seames like some other resources nedded where causing the crash.