Properly initialize WebEngineView
-
I've decided to add YouTube video playback feature in my app (in QML), so I choose
WebEngineView
As I watched the documentation I do this in
main.cpp
:QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QtWebEngineQuick::initialize();
Before initializing QCoreApplication.
And in my view i use this:
import QtWebEngine 1.10 ... WebEngineView { width: 600 height: 300 Component.onCompleted: { url = model.gameVideoUrl } } ...
This works but I have this message in output (happens when item initializes):
QWebEngineFileSystemAccessRequest is neither a QObject, nor default- and copy-constructible. You should not use it as a QML type. QWebEngineCertificateError is neither a QObject, nor default- and copy-constructible. You should not use it as a QML type. QWebEngineFullScreenRequest is neither a QObject, nor default- and copy-constructible. You should not use it as a QML type. QWebEngineLoadingInfo is neither a QObject, nor default- and copy-constructible. You should not use it as a QML type.
What am I doing wrong?
-
@Drazz
Seemingly same as https://github.com/OmixVisualization/qtjambi/issues/94#issuecomment-1290511207 ?
I don't know whetherQCoreApplication
(rather thanQApplication
) is enough for your purposes, but what happens if you do it before theQtWebEngineQuick::initialize();
?
Otherwise is it a harmless warning which should just be ignored, because of the order of initialization? -
Thanks for your answer.
In my case, I've tested WebEngine Quick Nano Browser example using Qt 6.4.3. It uses QGuiApplication and QtWebEngineQuick::initialize is called before creating the application instance.
If I move QtWebEngine::initialize() below QGuiApplication, I not only get the same warnings but also an additional message:
QtWebEngineQuick::initialize() called with QCoreApplication object already created and should be called before. This is deprecated and may fail in the future.
I like to take care of warnings whenever possible, as they can indicate potential issues. Is there any official explanation for these specific warnings?