There are two ways to modify image pixel data. The first one works only for QImage and involves direct manipulation of pixels using the setPixel() call, which takes the pixel coordinates and color to be set for that pixel. The second one works for both QImage and QPixmap and makes use of the fact that both these classes are subclasses of QPaintDevice. Therefore, you can open QPainter on such objects and use its drawing API. Here's an example of obtaining a pixmap with a blue rectangle and red circle painted over it:
QPixmap px(256, 256); px.fill(Qt::transparent); QPainter painter(&px); painter.setPen(Qt::NoPen); painter.setBrush(Qt::blue); QRect r = px.rect().adjusted(10, 10, -10, -10); painter.drawRect(r); painter.setBrush(Qt::red); ...