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. Why Slot is not getting called when timer is timeout
QtWS25 Last Chance

Why Slot is not getting called when timer is timeout

Scheduled Pinned Locked Moved Unsolved General and Desktop
10 Posts 4 Posters 570 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.
  • N Offline
    N Offline
    ndiwan
    wrote on last edited by
    #1

    m_Timer=new QTimer();
    m_Timer->setInterval(1000);
    connect(m_Timer, SIGNAL(timeout()), this, SLOT(flashColor()));

    void CIndicator::setBIsFlash(bool bIsFlash)
    {
    m_bIsFlash = bIsFlash;
    if(m_bIsFlash)
    {
    m_Timer->start();
    }
    else
    {
    m_Timer->stop();
    }
    }

    void CIndicator::flashColor()
    {
    if(getQcIndicatorColor() != getQcIndicatorFlashColor())
    {
    setQcIndicatorColor(getQcIndicatorFlashColor());
    }
    else
    {
    setQcIndicatorColor(getQcIndicatorColorBKP());
    }
    }

    I am sure than timer is starting

    JonBJ 1 Reply Last reply
    0
    • N ndiwan

      m_Timer=new QTimer();
      m_Timer->setInterval(1000);
      connect(m_Timer, SIGNAL(timeout()), this, SLOT(flashColor()));

      void CIndicator::setBIsFlash(bool bIsFlash)
      {
      m_bIsFlash = bIsFlash;
      if(m_bIsFlash)
      {
      m_Timer->start();
      }
      else
      {
      m_Timer->stop();
      }
      }

      void CIndicator::flashColor()
      {
      if(getQcIndicatorColor() != getQcIndicatorFlashColor())
      {
      setQcIndicatorColor(getQcIndicatorFlashColor());
      }
      else
      {
      setQcIndicatorColor(getQcIndicatorColorBKP());
      }
      }

      I am sure than timer is starting

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @ndiwan And are you equally sure your slot is not getting called?

      N Christian EhrlicherC 2 Replies Last reply
      0
      • JonBJ JonB

        @ndiwan And are you equally sure your slot is not getting called?

        N Offline
        N Offline
        ndiwan
        wrote on last edited by ndiwan
        #3

        @JonB yes I put a debug point on timer start and slot function. I am getting up to timer start, but then its not calling slot.

        1 Reply Last reply
        0
        • JonBJ JonB

          @ndiwan And are you equally sure your slot is not getting called?

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @JonB I would guess the slot is not declared as such so it's not found during runtime. That's the price to pay by not using the pmf syntax nowadays...

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          JonBJ 1 Reply Last reply
          2
          • Christian EhrlicherC Christian Ehrlicher

            @JonB I would guess the slot is not declared as such so it's not found during runtime. That's the price to pay by not using the pmf syntax nowadays...

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @Christian-Ehrlicher said in Why Slot is not getting called when timer is timeout:

            @JonB I would guess the slot is not declared as such so it's not found during runtime

            I have never used them, would that not produce some runtime warning message?
            I think the runtime connect() would at least return that error condition?

            Christian EhrlicherC N 2 Replies Last reply
            0
            • JonBJ JonB

              @Christian-Ehrlicher said in Why Slot is not getting called when timer is timeout:

              @JonB I would guess the slot is not declared as such so it's not found during runtime

              I have never used them, would that not produce some runtime warning message?
              I think the runtime connect() would at least return that error condition?

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @JonB said in Why Slot is not getting called when timer is timeout:

              would that not produce some runtime warning message?

              It will but only if you look at the console...🙂

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              1
              • JonBJ JonB

                @Christian-Ehrlicher said in Why Slot is not getting called when timer is timeout:

                @JonB I would guess the slot is not declared as such so it's not found during runtime

                I have never used them, would that not produce some runtime warning message?
                I think the runtime connect() would at least return that error condition?

                N Offline
                N Offline
                ndiwan
                wrote on last edited by ndiwan
                #7

                @JonB I just noticed that SLOT fnction is getting called but just once in a while, like once in 1.5 mints. But I set the timer to 1000 ms

                Pl45m4P JonBJ 2 Replies Last reply
                0
                • N ndiwan

                  @JonB I just noticed that SLOT fnction is getting called but just once in a while, like once in 1.5 mints. But I set the timer to 1000 ms

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

                  @ndiwan

                  So something else must be blocking the execution.
                  Strip your app down to just the timer and color function and see if it works


                  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
                  • N ndiwan

                    @JonB I just noticed that SLOT fnction is getting called but just once in a while, like once in 1.5 mints. But I set the timer to 1000 ms

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by JonB
                    #9

                    @ndiwan said in Why Slot is not getting called when timer is timeout:

                    @JonB I just noticed that SLOT fnction is getting called

                    How did you notice that? Did you put in debug statement or rely on seeing the color change?

                    Otherwise if this is not your whole program then follow @Pl45m4's advice.

                    N 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @ndiwan said in Why Slot is not getting called when timer is timeout:

                      @JonB I just noticed that SLOT fnction is getting called

                      How did you notice that? Did you put in debug statement or rely on seeing the color change?

                      Otherwise if this is not your whole program then follow @Pl45m4's advice.

                      N Offline
                      N Offline
                      ndiwan
                      wrote on last edited by
                      #10

                      @JonB I added a debug point.

                      1 Reply Last reply
                      0

                      • Login

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