Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Extending QtQuick.Controls ApplicationWindow to set OpenGL format
Forum Updated to NodeBB v4.3 + New Features

Extending QtQuick.Controls ApplicationWindow to set OpenGL format

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 2.2k Views 1 Watching
  • 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.
  • E Offline
    E Offline
    egorlarionov
    wrote on last edited by
    #1

    Hello everyone,

    I am trying to write a simple OpenGL desktop application using QtQuick with QtQuick.Controls. In particular I want to make use of the MenuBar, StatusBar, ToolBar etc. features defined in ApplicationWindow, in addition to an OpenGL view. It seems like I need to set the OpenGL format before (or during) my Window class is instantiated.
    My question is how do I set the OpenGL format (to OpenGL 3.3 Core Profile) without extending a QQuickWindow class (which is used by ApplicationWindow in QML I think) and doing this in the constructor. Alternatively, is it possible to link ApplicationWindow to a C++ class somehow so I can provide a custom constructor. Is there a initialization callback where I can set the format?

    I am using the QQmlApplicationEngine to process the main QML file. Maybe I need to use another QML engine?

    Any help is greatly appreciated!

    Thank you!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agocs
      wrote on last edited by
      #2

      I doubt there's an easy way to accomplish this. The surface format that is normally used (via QWindow::setFormat) to request a certain OpenGL version and profile is not exposed to QML and therefore there probably is no way to set it when creating windows from QML.

      You could experiment with keeping the ApplicationWindow hidden (visible: false), invoking some C++ code that calls setFormat() on it and then making it visible explicitly. If you can access the ApplicationWindow element from C++, a qobject_cast<QQuickWindow *> should give you the instance on which setFormat() can be called.

      1 Reply Last reply
      0
      • E Offline
        E Offline
        egorlarionov
        wrote on last edited by
        #3

        Using ApplicationWindow stuff is very convenient. It's unfortunate that one can't change their OpenGL version/profile when using it. This seems like a very typical use case for desktop application developers using OpenGL.
        I hope this will be fixed in a future version of Qt.

        Thank you for the suggestion!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved