monkeber
monkeber

Reputation: 81

Custom tray menu for the application

I have a Qt5 application and I want to add custom menu for the tray icon, but I don't want to make it look like a simple selection menu with list of actions, I want to make a complex widget which will contain several other widgets in custom layout (e.g. few buttons, additional menu, list of values with filtering option) something like on the screenshot. So the question is - which approach should I take for implementing this? Should I create QWindow which I will show on user click or is there another proper way for implementing this? I need this to work on Windows and Linux, I'm using Qt5. enter image description here

Upvotes: 1

Views: 260

Answers (1)

ypnos
ypnos

Reputation: 52317

Yes.

You create a QWidget (not QWindow) that you show() on QSystemTrayIcon's activated signal. A QWidget behaves like a standalone window when it has no parent. You can check the given reason or just show it in any case.

You might also want to position the widget based on either tray icon geometry or current mouse position. The former is the expected way to do it.

Note that it is also possible to embed custom widgets as actions in a menu. However, your example doesn't look like it fits a menu.

Upvotes: 1

Related Questions