Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Timer not working
QtWS25 Last Chance

Timer not working

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 5 Posters 1.5k 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.
  • R Offline
    R Offline
    Rashmi
    wrote on last edited by
    #1

    Hello,

    I am using qtimer having 500 ms time value in my project.
    While performing file sorting operation,I observed that timer expired event not generated.
    It means timer slot get blocked till file operation complete.

    I will appreciate your quick response.
    Thanks.

    jsulmJ kshegunovK 2 Replies Last reply
    0
    • m.sueM Offline
      m.sueM Offline
      m.sue
      wrote on last edited by
      #2

      Hi,
      how did you start the sorting operation? The timer fires the execution of a slot. If the file sorting is done in another already running slot, the timer slot will execute after the file sorting is finished as all slots work one after the other: its a message queue, after all.
      You may need to do the file sorting in another thread to make the timer slot run in parallel.
      -Michael.

      1 Reply Last reply
      2
      • kd_walaK Offline
        kd_walaK Offline
        kd_wala
        wrote on last edited by kd_wala
        #3

        is file sorting operation running on main thread? is your timer you create & start on main thread? document say: timer must run on thread that have event loop.

        1 Reply Last reply
        0
        • R Rashmi

          Hello,

          I am using qtimer having 500 ms time value in my project.
          While performing file sorting operation,I observed that timer expired event not generated.
          It means timer slot get blocked till file operation complete.

          I will appreciate your quick response.
          Thanks.

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

          @Rashmi Most probably your sorting operation is lasting for long time and blocks the event loop :-)
          For example this loop will block event loop until finished:

          while(SOME_CONDITION) {
          
          }
          

          As long as the event loop is blocked your slot will not be executed.
          To avoid such problems you should avoid blocking operations in Qt (actually in all event-driven frameworks). If you cannot avoid them then execute them in a different thread.

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

          1 Reply Last reply
          3
          • R Rashmi

            Hello,

            I am using qtimer having 500 ms time value in my project.
            While performing file sorting operation,I observed that timer expired event not generated.
            It means timer slot get blocked till file operation complete.

            I will appreciate your quick response.
            Thanks.

            kshegunovK Offline
            kshegunovK Offline
            kshegunov
            Moderators
            wrote on last edited by
            #5

            @jsulm said in Timer not working:

            As long as the event loop is blocked your slot will not be executed.

            Even something more, you'll get a single timer event after the whole interval. As explained in the docs:

            All timer types may time out later than expected if the system is busy or unable to provide the requested accuracy. In such a case of timeout overrun, Qt will emit activated() only once, even if multiple timeouts have expired, and then will resume the original interval.

            Read and abide by the Qt Code of Conduct

            1 Reply Last reply
            2

            • Login

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