PDA

View Full Version : Transparent image as QTableView cell



LynneV
29th October 2014, 15:15
I've seen a bunch of posts on how to display a transparent image in a table cell. I thought I'd contribute what my research found as the "easiest" way to achieve this result. Here is what I did:
1.make a png file (a file type that supports transparency - unlike bitmaps or jpg)
2.Reduce the color depth to something manageable (like 16 or even 256), and set one color as transparent
3.use this file as the source for QImage as the decoration role:
QImage img = QImage(header_image );
setData(QVariant(img), Qt::DecorationRole);
I haven't tested it with gradients or superimposed on other images... but so far it works very nicely with alternating background colors in a QTableView!