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

Post a Comment

Popular posts from this blog

Access GPIO from Linux user space

Android: adb push and read-only file system error

Tree in SQL database: The Nested Set Model