Tried wrapping code inside a Object and passing it to QtScript but this does not seem to work.
Added example for wrapping std::cout in a QObject slot and calling it from QStript. This should be enough to wrap QPainter.