PDA

View Full Version : Embedding SDL in a QWidget That is not a Window



PhilippB
21st August 2008, 12:17
Hi!

I'd like to use SDL for video overlay in a Qt4 application. At the moment I'm focussing on
Linux as target platform. (Other platforms are planned, so XVideo is not an alternative)
I already found information and examples about this at various places, but it seems that they do
not cover all my needs.

It seems, that I cannot have SDL emdedded in a widget that is part of a window layout (and not an
independant window). I'm using the SDL_WINDOWID hack to embed SDL in an already existing Qt window.
The best solution I have found yet, is creating a surface for the whole window and painting the
overlay only in the area occupied by the video widget. This works to a certain extend - but produces
a lot of flicker. Also, there are situations where theres no video shown at all.
(Presumably, the overlay has been covered by Qt's background painting - yes, I'm fighting against
the Qt paint model without knowing all details about it ;-) )

Then I started experimenting with Qt::WA_PaintOnScreen and Qt::WA_NoSystemBackground. I tried both,
setting them for the main window, and for the widget only (with focus on the latter). The result is,
that I don't see any painting effects of SDL at all, once I set these attributes.

The best example resource I found is the QxtSdlWidget class from the Qt Extension Library. But
it sets SDL_WINDOWID to winId(), which should only work when this widget is also a window.

Is there a way to embed SDL in a non-window widget?