PDA

View Full Version : Transparency problems with system tray in Windows



lliehu
8th December 2007, 15:29
I use a class named SvgIconEngine that is subclassed from QIconEngineV2 to paint the system tray's (QSystemTrayIcon) icon.



SvgIconEngine *engine = new SvgIconEngine;
engine->loadSvgFromFile(":/icon.svg");
mSysTray->setIcon(QIcon(engine) ); // mSysTray = QSystemTrayIcon


The paint code is the following:



void SvgIconEngine::paint(QPainter *painter, const QRect& rect,
QIcon::Mode mode, QIcon::State state)
{
mRenderer.render(painter, rect); // mRenderer = QSvgRenderer object
}


In Windows XP I have this problem:
http://www.kolumbus.fi/lliehu/sekalaista-tavaraa/bad_systemtrayicon.png

Where there should be the transparency there are some weird colorful pixels which undoubtedly are not part of system tray's background.

I have this problem only in Windows. In Linux/KDE everything works perfectly.

Anyone has an idea?

jpn
8th December 2007, 16:00
Does it have any effect if you insert the following line:


void SvgIconEngine::paint(QPainter *painter, const QRect& rect,
QIcon::Mode mode, QIcon::State state)
{
painter->fillRect(rect, Qt::transparent); // <---
mRenderer.render(painter, rect); // mRenderer = QSvgRenderer object
}

?

PS. Attach images instead of using links to external sites, please.

lliehu
8th December 2007, 16:37
Does it have any effect if you insert the following line:


painter->fillRect(rect, Qt::transparent); // <---

?

PS. Attach images instead of using links to external sites, please.

No it doesn't. But thanks. And I didn't know you can attach an image. I'll do that next time.