Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Changing tray Icon on signal

Changing tray Icon on signal

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 4 Posters 245 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    __d4ve__
    wrote on last edited by
    #1

    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

    Pl45m4P jsulmJ C 3 Replies Last reply
    0
    • _ __d4ve__

      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

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #3

      @__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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • _ __d4ve__

        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

        Pl45m4P Offline
        Pl45m4P Offline
        Pl45m4
        wrote on last edited by
        #2

        @__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 to

        emit syncChanged(true);
        

        since you never emit false anyway.

        Where do you call this function? Are you blocking the event loop somewhere?


        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

        ~E. W. Dijkstra

        1 Reply Last reply
        0
        • _ __d4ve__

          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

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #3

          @__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?

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • _ __d4ve__

            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

            C Offline
            C Offline
            ChrisW67
            wrote on last edited by
            #4

            @__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.

            1 Reply Last reply
            0
            • _ Offline
              _ Offline
              __d4ve__
              wrote on last edited by __d4ve__
              #5

              Client to instance instead of object and

              Client->moveToThread(thread);
              

              solved the problem

              1 Reply Last reply
              0
              • _ __d4ve__ has marked this topic as solved on
              • _ __d4ve__ has marked this topic as solved on

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved