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();

Comments

Popular posts from this blog

Access GPIO from Linux user space

Launch an app from Android shell terminal

Qt 5 and " Failed to load platform plugin 'windows' " error