There actually is no problem with my code per se, but if I add my program to run on startup (i.e. every time the user logs in), it fails to create the tray icon, because, at the time it tries to, the taskbar is not yet created/initialized completely. Is there a solution for that? Right now I'm thinking about something like retrying 10 times with a 10 second interval.
It certainly is a race condition. Retrying is a good idea, yes, but instead I'd do it with delays. Have the app launch but use a QTimer::singleShot() to delay for 5 seconds (or whatever) before trying to hookup with the taskbar. If you want to retry after that (which is probably a good idea), delay longer (as retrying immediately likely won't succeed either as the retry will occur too fast).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With