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. Display a OpenGL QWindow in QML
Forum Updated to NodeBB v4.3 + New Features

Display a OpenGL QWindow in QML

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 3 Posters 1.5k 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.
  • J Offline
    J Offline
    john_god
    wrote on last edited by
    #1

    Hello good people

    I have a QML main file

    @Rectangle {
    id: root
    width: 640
    height: 480
    color: "#fff396"

    property int margin: 10
    MenuHybrid{ // this is just a QML menu with QML buttons
        id: menu
        anchors.top: parent.top
        anchors.left: parent.left
        anchors.margins: margin
    }
    

    //How to display a QWindow class with Opengl in replace of this black rectangle ???
    Rectangle {
    id: drawingBoard
    color: "black"

        anchors.left: parent.left
        anchors.bottom: parent.bottom
        anchors.right: parent.right
        anchors.top: menu.bottom
        anchors.margins: margin
    }
    

    }
    @

    I have added to the project a c++ QWindow class, I don't know how to display it in QML.
    I've read the docs about the QML and C++ integration, but still haven't figure out weel the logic.
    Basically I want to achieve a fancy QML paint application, with a menu with buttons and QGLWidget area, so the user draws stuff with mouse clicks. Since QGLWidgets is not recommended for QML app, I believe, I'm thinking of a QWindow class.
    Thanks

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      QGL* stuff is pretty much deprecated, consider moving to QOpenGL* classes instead.

      And: every QML Item is an OpenGL painter, so you can also think about subclassing QQuickItem (OpenGL, you need to push the result into a texture to have it drawn) or QQuickPaintedItem (uses QPainter!).

      I'm far from being an expert here, though. Would be nice if others joined in.

      (Z(:^

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Nexelen
        wrote on last edited by
        #3

        You can look my example "project":https://github.com/nexelen/Qt5OpenGLStudy .

        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