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
Forum Updated to NodeBB v4.3 + New Features

Timer not working

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
5 Posts 5 Posters 1.5k Views 1 Watching
  • 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 19 Oct 2016, 09:01 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.

    J K 2 Replies Last reply 19 Oct 2016, 10:12
    0
    • M Offline
      M Offline
      m.sue
      wrote on 19 Oct 2016, 09:48 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
      • K Offline
        K Offline
        kd_wala
        wrote on 19 Oct 2016, 10:07 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
          19 Oct 2016, 09:01

          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.

          J Offline
          J Offline
          jsulm
          Lifetime Qt Champion
          wrote on 19 Oct 2016, 10:12 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
            19 Oct 2016, 09:01

            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.

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 19 Oct 2016, 11:16 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

            2/5

            19 Oct 2016, 09:48

            • Login

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