Qt World Summit: Submit your Presentation

Qt Quick 2 with OpenGL > 2.0

  • Good afternoon everybody. I faced with a problem which I can't solve myself.

    I want to use Qt Quick 2.x for my program but I can't make it work with OpenGL > 2.0

    I have main.qml:

    @ /* imports */
    Window {
    Scene {

    In Scene I'm using OpenGL > 2.0 so my shaders aren't working.

    I've tried to add this line qobject_cast<QQuickWindow*>(engine.rootObjects().first())->setFormat(format_3_3); in main.cpp but that didn't help.

    @int main(int argc, char *argv[])
        QGuiApplication app(argc, argv);
        QSurfaceFormat format_3_3;
        qmlRegisterType<Scene>("SceneGL", 1, 0, "Scene");
        QQmlApplicationEngine engine;
        return app.exec();

    My Scene class:

    @class Scene : public QQuickItem

    I found a solution "here (47 minute)":http://www.youtube.com/watch?v=GYa5DLV6ADQ: but without source code I can't see full picture to use the same technique.

    How can I solve this problem? Thanks for your answers.

  • Moderators

    Are you running this on Windows with ANGLE, by any chance?

  • Nope, MAC OS X 10.10

  • A QWindow's surface format must be set before the window is created. In Qt version including 5.3.2 you'll need to create the Window from the C++ side by using a QQuickView.

    In Qt 5.4 you can call QSurfaceFormat::setDefaultFormat to set a default format that the QtQuick Window element also will use.

  • Thanks, that helped but now I faced with another problem: "problem":http://qt-project.org/forums/viewthread/49501/

Log in to reply