PDA

View Full Version : possible to convert string/numbers to tray icon?



jarmok
19th July 2008, 17:28
i have tried the trolltech example that creates system tray but i havent been able to find a way to convert string or value to icon so i could create weather application that shows temperature in system tray. is this possible in qt or do i have to create own icon for each number?

this was possible at least in c#
http://blogs.msdn.com/abhinaba/archive/2005/09/12/animation-and-text-in-system-tray-using-c.aspx

thanks.

honza
19th July 2008, 18:49
TrayIco::TrayIco( QWidget * parent, Qt::WFlags f)
: QMainWindow(parent, f)
{
setupUi(this);

QPixmap pixmap(16,16);
pixmap.fill(Qt::transparent);
QPainter painter(&pixmap);
QString string;
string = "48";
painter.drawText(0,0,16,16,Qt::AlignHCenter | Qt::AlignVCenter, string);

ico = new QSystemTrayIcon(this);

ico->setIcon(QIcon(pixmap));

ico->show();
}

jarmok
19th July 2008, 19:34
cool it worked.thanks