Details
-
Suggestion
-
Resolution: Won't Do
-
Not Evaluated
-
None
-
6.4.2
-
None
Description
If the QT application and WebEngine is initialized from an own thread, then it is required to set the QCoreApplicationPrivate::theMainThread first to get ride of all warnings.
Note that in our application it is required to use a dedicated thread and the initialization cannot be performed on the main thread.
I have tried 3 different variants. See also attached project.
Variant 1 as shown by https://doc.qt.io/qt-6/qtwebengine-overview.html
QGuiApplication app(argc, argv);
QtWebEngineQuick::initialize();
==> shows Warnings
WARNING: QApplication was not created in the main() thread.
QtWebEngineQuick::initialize() called with QCoreApplication object already created and should be call before. This is depreciated and may fail in the future.
Variant 2
QtWebEngineQuick::initialize(); QGuiApplication app(argc, argv); ==> shows Warning WARNING: QApplication was not created in the main() thread.
Variant 3 - Works without warnings but is not nice as it requires private includes of QCoreApplication
#include <QtCore/private/qcoreapplication_p.h>
auto thread = QThread::currentThread();
QCoreApplicationPrivate::theMainThread = thread;
QtWebEngineQuick::initialize();
QGuiApplication app(argc, argv);
Suggestion: Make it possible to set QCoreApplicationPrivate::theMainThread somehow from the QCoreApplication.
static QCoreApplication::useCurrentThreadAsMainThread()