4
votes

I'm currently trying to get Qt working with my existing program.

I'm using SFML for creating my OpenGL rendering context and creating the window. The things I tried out so far however always create a separate window by Qt instead of just rendering into the existing context.

Is there any way I can force Qt to render to an already existing OpenGL context?

2
Why would you want to make Qt render OpenGL stuff to a non-Qt Window? In general, these APIs (SFML, Qt, etc) like to own the windows they render to. Rendering to someone else's window which they have no control over is generally not well supported. If for no other reason than the fact that there is no universal API for "window" that you could pass between them... - Nicol Bolas
The reason is I'm trying to find out if using Qt's GUI library would work by embedding it into an existing application using OpenGL for providing UI. The program I'd like to use it for is too big to adjust it to use Qt for everything, so I wondered if one can use the GUI part of it only. - stschindler

2 Answers

3
votes

I've not looked into the specifics, but this has been done for openage.

I think looking at the documentation for QQuickRenderControl might be a good place to start.

1
votes

Qt wants full control over the windows and the event loop, so this will not work (unless you put a lot of effort into it). Your best bet is using a QGLWidget and emulate the event management of SFML with that, so that your application effectively runs on Qt. It is very well possible to render Qt widgets into a OpenGL window (Qt has a OpenGL widget backend) but this must be still managed by Qt itself.