Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Unsolved openglContextCreated signal not emitted

    QML and Qt Quick
    2
    2
    150
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      Andy999 last edited by Andy999

      Hello everyone!

      I would like to ask what's wrong with OpenGL context signal.
      Previously everything was working, until I didn't upgrade QT 5.9.5 -> 5.12.5. Compilation was successful, so I wasn't expecting any problems.

      Currently I am using QT 5.12.5 on embedded platform based on Yocto.

      // 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;
        engine.load(QUrl(QUrl("./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();
      }
      

      Application startup:

      ./egl_test -platform eglfs --no-sandbox
      QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/var/volatile/tmp/runtime-root'
      Setting framebuffer size is only available with DRM atomic API
      Unable to query physical screen size, defaulting to 100 dpi.
      To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).
      isValid:  true
      started
      

      From the documentation (https://doc.qt.io/qt-5/qopenglcontext.html#isValid) I can see Returns if this context is valid, i.e. has been successfully created.. So the signal openglContextCreated wasn't emitted even if, the openglContext is valid already

      Same code on 5.9.5 works without any problems. Signal is emitted and validity check is false, because OpenGL content there is not valid.

      So what's wrong there?

      Thank you,
      Andy

      1 Reply Last reply Reply Quote 0
      • A
        Andy99 last edited by

        Solved by setting visible: false then calling ->show() showe the window, when I wanted. Later the signal was emitted without problems as before.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post