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. Is it worth to start and stop QTimer ?
Forum Updated to NodeBB v4.3 + New Features

Is it worth to start and stop QTimer ?

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.3k 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.
  • P Offline
    P Offline
    Patrick2391
    wrote on last edited by
    #1

    I am using QTimer of pyside library in my code.
    I have QT application containing items in listwidget and tabwidget having 3 tabs(0, 1, 2).

    I have to update some value on "tab 1" periodically (periodicity will depend on item selected)

    What i am doing:
    I wrote a callback for updating value on "tab 1".
    Created timer initially and connected callback to it.
    Starting timer when "tab 1" is clicked for 1st time and timeout will depend on selected item in listwidget

    I thought of two cases of doing it:
    if "tab 1" is selected and start timer is not alive:

    1. whenever an item is selected stop the timer and again start it with new timeout (of selected item)
    2. change timeout of timer and no need to stop and start it.

    if "tab 0" and "tab 2" selected:
    stop timer

    I need to take a decision on which method to use when "tab 1" is selected.

    I prefer 2nd method but on QTimer documentation i read that changing timeout will change timerID. I don't know how much this affects or adds overhead.

    Please give your views about these 2 methods and Which method is technically good ?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      The question is: are you using the timer id at any point in your code ? If not then just update the interval

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • P Offline
        P Offline
        Patrick2391
        wrote on last edited by
        #3

        I am not using timer id in code.
        But i want ot know technical (or internal or in terms of overhead) differences between those 2 methods.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Then you should take a look directly in QTimer's sources

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          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