I was wondering if I could use Cairo from Qt3. Given that Cairo allows creating surfaces from X11 visuals and that Qt allow accessing them, I thought it was simple. As a proof, here is the interesting bit (using Qt3 and Cairomm, the C++ "bindings" for Cairo):

QSize size = QWidget::size();
RefPtr<Surface> surface = Cairo::XlibSurface::create(

That code is from a member method of a QWidget subclass.

Get the code: main.cpp. To build, use the following command:

gcc main.cpp -o main -I/usr/include/qt3 -I/usr/include/cairo -I/usr/include/cairomm-1.0 \
 -lqt-mt -lcairo -lcairomm-1.0

Now lets think how to make that API clean, and how QPainter will conflict with it :-)

Update (July 30th): I got pointed to qcairo in the cairo-demo. I must admit I didn't really look for one as I liked the educational part of figuring things out (easy).