But it looks like QPainter will do exactly what I need, thanks!
Thats how it is done in Qt.

To be honest, I never really considered QPainter. I was trying to do this as low-level as possible to reduce the overhead introduced by Qt's painting framework.
Then why use Qt... there will be some overhead still :P
juzz kidding.. theres always tradeoff between complexity of code and runtime. And Qt's paint framework is not that slow..also if you use QPainter, your code will be cross platform !