Sections

How can I draw a pixmap with a background color after the pixmap is constructed from an image?

Entry number: 562 - How can I draw a pixmap with a background color after the pixmap is
constructed from an image?

Answer:

You can create a second pixmap, fill it with your background color, then draw the original pixmap on top. For example:

QPixmap filled(original.size());
QPainter paint(&filled);
paint.fillRect(0,0,original.width(), original.height(), backgroundColor);
paint.drawPixmap(0,0,original);
paint.end();

This approach will work in both Qt 3 and Qt 4.

back

Patron of KDECustomers

Customers