Changing tray Icon on signal
-
Hi ,
I have trayIconApp class that has this connect() function to change tray icon
connect(&client, &Client::syncChanged, this, &TrayIconApp::onSyncChanged);
I have checked the connection is valid , setSync runs and "emit syncChanged request sent." get printed ,
signal declared under public.void Client::setSync(bool sync) { if (sync == true) { qDebug() << "emit syncChanged request sent."; emit syncChanged(sync); // Emit the signal if 'sync' changes } }
the following function not seems to run though sync value is set to true
void TrayIconApp::onSyncChanged(bool sync) { qDebug() << "onSyncChanged called with:" << sync; if (sync) { qDebug() << "Updating tray icon to connected."; updateTrayIcon_connected(); } else { qDebug() << "Updating tray icon to terminated."; updateTrayIcon_terminated(); } }
I'm using :
Product: Qt Creator 13.0.0
Based on: Qt 6.6.0 (MSVC 2019, x86_64)
Built on: Apr 2 2024 12:11:52
From revision: b887825661 -
@__d4ve__ said in Changing tray Icon on signal:
connect(&client, &Client::syncChanged, this, &TrayIconApp::onSyncChanged);
Where is "client" created? Do you maybe have another one somewhere?
-
@__d4ve__ said in Changing tray Icon on signal:
if (sync == true) { qDebug() << "emit syncChanged request sent."; emit syncChanged(sync); // Emit the signal if 'sync' changes }
Is it just for testing?
Otherwise it can be changed toemit syncChanged(true);
since you never
emit false
anyway.Where do you call this function? Are you blocking the event loop somewhere?
-
@__d4ve__ said in Changing tray Icon on signal:
connect(&client, &Client::syncChanged, this, &TrayIconApp::onSyncChanged);
Where is "client" created? Do you maybe have another one somewhere?
-
@__d4ve__ Further to @jsulm's question, you may find it useful to add this at the top of the TrayIconApp constructor/destructor
qDebug() << "Construct" << this; qDebug() << "Destruct" << this;
and this in the slot:
qDebug() << this << "onSyncChanged called with:" << sync;
Then you will see which TrayIconApp object gets created and which object, if any, receives sent signals.
What is the life span of
client
? In your connect(),client
appears to be a stack-based instance of the Client class. -
-