Hi,
I'm trying to set transparent icons in a QAction, which is then added to a Menu and a toolbar. I'm styling the application with a style sheet. The icon transparency works, but the icons are being drawn on the toolbar with what looks like a 1px black border on the left and top edges of the icons.
Now, all my icons are stored in one large image file (PNG, with transparency) - they're saved in one large strip. To extract them into a single QIcon, I do this:
// load icon strip:
QPixmap large;
large.load(":/icons/tb_icons_l.png", "PNG", Qt::OrderedAlphaDither);
QSize largeSize(large.width() / ICON_COUNT, large.height());
// create individual icon pixmap
QPixmap iconLarge(largeSize);
// fill with transparent pixels:
iconLarge.fill(QColor(0,0,0,0));
// copy pixel data from icon strip to image:
{
QPainter p(&iconLarge);
p.setBackgroundMode(Qt::TransparentMode);
p.drawPixmap(0,0,large, largeSize.width() * i, 0, largeSize.width(), largeSize.height()); // 'i' is the icon index.
}
return QIcon(iconLarge);
I know the problem is in the few lines above, since when I load icons from individual files instead this all works perfectly ( no black border).
Has anyone else seen anything like this before? Can anyone suggest some changes that will remove the unsightly black border? The border is definitely part of the image, rather than part of the toolbar button itself.