Important: Please read the Qt Code of Conduct -

OpenGL render inside a QGraphicScene

  • Hello,
    i am working with a software which has a QGraphiScene, on which are added tons of QGraphicsItems, which are my widgets (even if they are NOT QWidget, but only QGraphicsItems).

    What i need to do, is to define a new my widget (which can live with others) which render a OpenGL scene.

    I have taken a look on the web, but this seems not possible... any clue please?

    This is my first topic on this forum, so please sorry if i am in wrong section.

  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Not a direct answer but this stack overflow answer might give you a starting point.

    Hope it helps

  • Hello and many thanks for answer. I am not fully sure to understand the discussion on overflow. He says that "he renders opengl triangle inside QGraphicItems". But how this is possible? I suppose he must define a new custom QGraphicGLItem, inheriting the QOpenGLFunctions at least?

    Another story is the problem he had, resolved by compiling shaders in setViewport function (which is a nice tip).


  • Sorry if i am stupid, but i am really confused. I have tried to call openGL functions inside QGraphicsItem, but i get a crash (QtOpenGLFunctions not inited).

  • Lifetime Qt Champion

    Without the code you are using, it's difficult to help you. From the error you get, you are using the QOpenGLFunctions class but you never initialized it.

Log in to reply