January 11, 2012

alexandros alexandros
Ant Farmer
114 posts

Tray icon is not launching the activated() signal

 

Hello, I’m working in Ubuntu 11.10, and I have the following problem:
I call this to connect the tray to the SIGNAL:

  1. connect(trayIcon,SIGNAL(activated(QSystemTrayIcon::ActivationReason)),this,SLOT(clickSysTrayIcon(QSystemTrayIcon::ActivationReason)));

but as I checked, clickSysTrayIcon() function never launches! So, even if I’ve set to do something on single click (trigger) or to quit application on middle click, using this code:
  1. void MainWindow::clickSysTrayIcon(QSystemTrayIcon::ActivationReason reason)
  2. {
  3.     //reason is a variable that holds the type of activation or click done on the icon tray
  4.     switch (reason) {
  5.     case QSystemTrayIcon::Trigger:
  6.         //normal click
  7.         if(must_do_action){
  8.             do_action();
  9.             return;
  10.         }
  11.         if(!pref && !histor){//hide the icon
  12.             trayIcon->hide();
  13.             //show the main window
  14.             this->showNormal();
  15.         }
  16.         break;
  17.  
  18.     case QSystemTrayIcon::MiddleClick:
  19.         //quit the application
  20.         close();
  21.         break;
  22.     case QSystemTrayIcon::Unknown:
  23.         break;
  24.     case QSystemTrayIcon::Context:
  25.         break;
  26.     default :
  27.             ;
  28.     }
  29. }

nothing’s working… When I click the application the menu I’ve designed shows up and I can click the actions I’ve specified, which are working fine. Middle click to close app or normal click so as to do an action or to open the mainwindow, does not work.

Any ideas?

3 replies

January 11, 2012

Volker Volker
Robot Herder
5428 posts

It works for me (no MiddleClick on the Mac, though).

January 11, 2012

alexandros alexandros
Ant Farmer
114 posts

Hello Volker, thanks for the info. I (maybe :D) forgot to add that Ubuntu doesn’t really support tray icons and by default accepts indicators. In some cases, (I think especially if tray icons are Qt ones) it does accept tray icons but it may have disabled some functions of them. This may cause the problem, but any other thoughts rather than this?

PS: does QtCreator plan to make a library which supports indicators?

Thanks!

January 12, 2012

Volker Volker
Robot Herder
5428 posts

That would be a feature of the Qt libs, not Creator :-) Unfortunately, I don’t know about that. But with Ubuntu/Unity being based on Qt, I would say the chances are not too bad…

 
  ‹‹ password entered not able to retrieve      QTimers spawn new threads every time? ››

You must log in to post a reply. Not a member yet? Register here!