Qt Snippet: Draw into QPixmap


Draw inside QPixmap can be made using QPainter object. Basically you have to pass to QPainter the pointer to your QPixmap (already created with fixed size) and you can draw inside as the same of window area painting.


QPixmap MyPixamp(QSize(32,32));
QPainter Painter;

Painter.begin(&MyPixamp);
// Here paint inside QPixmap
Painter.setPen(QPen(QBrush(Qt::red), 1, Qt::DashLine));
Painter.drawRect(0,0,32,32);
// ...
Painter.end();

0 Comments:

Post a Comment