Results 1 to 5 of 5

Thread: QTimer - too many in application??

  1. #1
    Join Date
    Feb 2007
    Posts
    48
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTimer - too many in application??

    I'm having a problem with QTimer and hope someone can set me straight. I've been through the posts and haven't found a similar situation.

    I have a QMainWindow application that has 15 menu selections. Each of these menu selections starts a new QDialog widget that contains a QTableView with an associated data model. The responsibility of each of these dialog widgets is to update the model with data from a shared memory segment that is always changing.

    Each dialog widget has a QTimer associated with it since I want to update the data at a couple of different time rates. Some are 1 sec others are .5 sec. When the widget is shown the timer is started and when the widget is minimized the timer is stopped.

    The problem is that when I have several (5) of the widgets displayed (all these have 1 sec timers) some update at 1 sec, others update at odd intervals like 4, 6, 7, 9, (...etc) seconds.

    Is there such a thing as too many timers in a QT application?
    Could the timers be interferring with each other?
    Is there a better (simpiler) approach that I'm missing?
    Would it be better to start each of these dialogs in their own thread (thats a lot of threads)?

    Any help/discussion would be helpful. Thanks in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Lightbulb Re: QTimer - too many in application??

    One possibility is that updation of the model is proving to be too costly. Have you checked which part of your code is slowing the things down?
    If i've understood you correctly, then each of the table view has a separate model and the model refreshes its data from the shared data source.
    If the problem is about refreshing the model, then you can create a custom model which manage the shared data source (in other words, convert the shared data object into a model) and then share that same model object everywhere.

  3. #3
    Join Date
    Feb 2007
    Posts
    48
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer - too many in application??

    Thanks for the input. However the problem is not in getting the correct data, that works fine and when the time goes off the correct data is displayed. Access is via a memory pointer into linux shared memory structure.

    The actually problem is in getting all the timers to timeout at their set time (1 sec). I agree it must be slowing it down, but not sure why.

  4. #4
    Join Date
    Jan 2006
    Location
    India
    Posts
    115
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTimer - too many in application??

    Timer won't fire at correct time if your app is doing expensive operations. Number of timers is not the root cause of delay. Use qtime or something similar to check which function is consuming more time.

  5. #5
    Join Date
    Feb 2007
    Posts
    48
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer - too many in application??

    OK. I'll give it a try

Similar Threads

  1. dll + application
    By fpujol in forum Qt Programming
    Replies: 11
    Last Post: 15th April 2007, 18:37
  2. Replies: 5
    Last Post: 6th March 2007, 05:34
  3. Replies: 3
    Last Post: 8th December 2006, 18:51
  4. Replies: 3
    Last Post: 31st March 2006, 18:38

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.