Baron Leonardo
Baron Leonardo

Reputation: 339

Qt : how to set text to QSystemTrayIcon?

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

Upvotes: 6

Views: 1334

Answers (1)

folibis
folibis

Reputation: 12854

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);

Upvotes: 11

Related Questions