PDA

View Full Version : QSystemTrayIcon to handle both double left click and single left click!



chandan
26th April 2012, 11:41
I am trying to achieve two different things when the user left single click and left double click on my tray icon. Left single click will only display the context menu and left double click will start the application. But unfortunately it is not working, because my slot for activated signal only handles trigger when the user double click my tray icon. Any thought will be very helpful. Thanks.

viulskiez
26th April 2012, 12:06
How you handle QSystemTrayIcon::ActivationReason? If i'm not mistaken, when user double-clicked the tray icon, QSystemTrayIcon::activated signal emitted twice, first it send QSystemTrayIcon::Trigger, after that it send QSystemTrayIcon::DoubleClick.

chandan
26th April 2012, 12:24
You are absolutely right. My code is handling trigger signal but ignoring the DoubleClicked signal. I don't know why, any idea?

viulskiez
26th April 2012, 12:28
Can you post the source code for handling activate signal?

chandan
26th April 2012, 12:43
Here is my code.


void SystemTray::onSystemTrayLeftClicked( QSystemTrayIcon::ActivationReason Reason )
{
updateTrayStates( ) ;

if ( Reason == QSystemTrayIcon::DoubleClick )
{

m_pActionTrayLogin->trigger() ; //
} else if ( Reason == QSystemTrayIcon::Trigger ) {

this->contextMenu()->popup(QCursor::pos());
}
}

viulskiez
26th April 2012, 12:45
Please use [code] tag to format code.

chandan
26th April 2012, 12:48
Thanks for reminding me. But that was a type-o.

viulskiez
26th April 2012, 15:45
My code is handling trigger signal but ignoring the DoubleClicked signal
Have you debug? Are you sure the slot doesn't called when the tray icon double-clicked?