Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt : how to set text to QSystemTrayIcon?

Tags:

c++

qt

I want to dynamically set the text instead of Icon in QSystemTrayIcon. How it is possible ?

like image 265
Baron Leonardo Avatar asked Aug 01 '14 10:08

Baron Leonardo


1 Answers

Tray icon is not designed to show text, just small image. Also, you can set tooltip message as @Merlin069 said, show balloon message or create context menu.

Of cource, you can create an image in you program and draw some text on it:

QPixmap pixmap(24,24);
pixmap.fill(Qt::white);
QPainter painter(&pixmap);
painter.drawText(pixmap.rect(),Qt::AlignCenter,"Hi!");
icon.setIcon(pixmap);
icon.setToolTip("Hi!");
icon.setVisible(true);
like image 52
folibis Avatar answered Nov 03 '22 15:11

folibis