Details
-
Bug
-
Resolution: Out of scope
-
P2: Important
-
None
-
5.12
-
None
-
Ubuntu 18.04, QT 5.9.5
Yocto Warior, QT 5.9.5, 5.12.5, 5.12.9
Description
Hello Everyone!
I'm not sure, if it's a bug or feature. So rather, I will describe it.
I've upgrade QT from 5.9.5 to 5.12.5 (tested also on latest LTS 5.12.9). Previously engine.load didn't init the OpenGL content. It was showed only, when a derivated window->show() or app.exec() was called. Which I think, was the right behavior.
After an upgrade, engine.load methods automatically inits the graphic content and emits openglContextCreated signal. So I can't connect to it, because root object is not available before load. But after load, it's too late.
// main.qml import QtQuick 2.0 import QtQuick.Window 2.0 import QtWebEngine 1.0 Window { width: 1024 height: 600 visible: true WebEngineView { anchors.fill: parent url: "http://localhost" } }
// main.cpp #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QtWebEngine> #include <QWindow> #include <QQuickWindow> #include <QOpenGLContext> #include <QDebug> void CheckOpenGLContext(QOpenGLContext* ogl_contex) { qDebug() << "CheckOpenGLContext()"; } int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QGuiApplication app(argc, argv); QtWebEngine::initialize(); QQmlApplicationEngine engine; // !!! problem is here engine.load("./main.qml"); QQuickWindow* window = qobject_cast<QQuickWindow*>(engine.rootObjects().first()); QObject::connect(window, &QQuickWindow::openglContextCreated, [&](QOpenGLContext* ogl_ctx){ CheckOpenGLContext(ogl_ctx); }); if(window->openglContext() != nullptr) qDebug() << "isValid: " << window->openglContext()->isValid(); qDebug() << "started"; return app.exec(); }
QT outputs:
5.9.5: started CheckOpenGLContext() 5.12.x: isValid: True started
Verified on independent OS/machines, but with the same QT versions.