Created a project in qtcreator, made several forms in it. In MainWindow, made the tray icon QSystemTrayIcon. How now from another form to work with this icon (for example, setIcon or showMessage).

I would be grateful for a specific example in the form of a qtcreator project.

  • one
    Send a pointer or a link, or from another form, send a signal that will interact with setIcon / showMessage - gil9red
  • Thank you, figured out. - posix
  • Decide the answer then you decided, otherwise other people will stumble upon your question, and you have only “thank you, you figure it out”: D - gil9red

1 answer 1

In the target form we do:

.h

public: QSystemTrayIcon *trayIcon; 

In the parent, open the target and pass the pointer:

.cpp

 if(!childForm->isVisible()){ childForm->trayIcon = trayIcon; childForm->show(); } 

Now in the target form we can do for example:

 trayIcon->showMessage(title, text, QSystemTrayIcon::Information, 1000);