So I've been working on a project for a while now in which I am integrating SFML and Qt5. I'm just using SFML for drawing. But I have not found any really good way to manage it.
I have tried three different techniques so far:
1) create a sf::RenderWindow from my QWidget::winId() and set the QWidget attribute WS_PaintOnScreen
This works to a certain extent, but besides only working properly on Linux (which will be a problem) it causes other issues (I get lots of errors pertaining to QBackingStore::flush() and QWidget::paintEngine())
2) render into a sf::RenderTexture, then copy the texture to a sf::Image, load the data into a QImage and draw onto the QWidget with a QPainter.
This also worked to some extent, but besides the obvious performance hit that this method would cause, the pixel format used in sf::Image is not compatible with QImage, so some of the color channels get mixed up.
3) use a QGLWidget instead of a QWidget, create a sf::RenderWindow from my QGLWidget::winId(), and do painting inside of QGLWidget::paintGL().
I was kind of surprised that this worked at all, but I don't know the details of opengl or the way it is used in wither SFML or QGLWidget, so maybe someone can explain the behavior I observed. I understand that SFML's version of opengl may not be supported in Qt5, so that's probably part of the problem. But some things worked, such as drawing lines, shapes, etc. Loading textures did not work. I also got several opengl errors pertaining to invalid calls. What confused me about this was that I thought sf::RenderWindow QGLWidget would each create its own context, so I didn't really expect it to work at all. Then again, I don't know much about opengl.
Anyways, does anybody know a correct, cross-platform way to integrate sf::RenderTarget into Qt Widgets? The only material I've been able to find is outdated--it deals with Qt4 and SFML 1.6. Also, I guess I could roll back to Qt4 if absolutely necessary, but I'd really like not to.