Results 1 to 4 of 4

Thread: QTimer stops after system time change

  1. #1
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTimer stops after system time change

    I am making an application on embedded linux (ARM - PXA255) with Qt for Embedded Linux 4.5.1 and I have a problem with QTimer when I change system time (another process or command line).

    When I change the system time forward the timer triggers timeout() signal immediately, but when I change the system time backward the timer never (or maybe it just takes too long) triggers timeout() signal.

    What I want is for timer to trigger timeout() signal on the desired interval in "real" time.

    I am working with intervals of 1 second or grater.

    Is there a simple solution to this, or should I just create a new timer class that uses "native" linux functions and just sent the timeout() signal from this new timer class?

  2. #2
    Join Date
    Jan 2006
    Location
    Alingsås, Sweden
    Posts
    437
    Thanks
    3
    Thanked 39 Times in 39 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer stops after system time change

    Using the native function is "dangerous", as you can mess up the Qt threading and timer system by introducing other sources of timer events.

    Have you tried experimented with QObject's startTimer, stopTimer and timerEvent? Perhaps you can make that work.

  3. #3
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer stops after system time change

    Quote Originally Posted by e8johan View Post
    Using the native function is "dangerous", as you can mess up the Qt threading and timer system by introducing other sources of timer events.

    Have you tried experimented with QObject's startTimer, stopTimer and timerEvent? Perhaps you can make that work.
    Tried it, but it still wont work, probably because QTimer user these functions.

    I tried one simple "native" timer and it worked for smaller changes in time, but when this time difference is big the "native" timer also fails.

  4. #4
    Join Date
    Jul 2007
    Location
    Slovenia
    Posts
    14
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer stops after system time change

    So I fixed my problem.

    First I had to use newer glibc (2.3.2 -> 2.3.3), then I had to find out if my embedded system can use monotonic timers (I wrote a simple timer class that acted like QTimer, but it used clock_nanosleep and clock_gettime for sleep).

    The I had to find out what is the problem with Qt, and it appears that Qt doesn't detect monotonic timers on my embedded system.
    So I changed the variable "useMonotonicTimers" to "true" in qeventdispatcher_unix.cpp (line 266) and recompiled Qt. Now it works correctly.

Similar Threads

  1. System time changed event
    By varunjajee in forum Qt Programming
    Replies: 2
    Last Post: 8th April 2009, 06:05
  2. Replies: 0
    Last Post: 28th February 2009, 23:18
  3. Replies: 1
    Last Post: 21st August 2008, 08:29
  4. Show System Time Stamp ??
    By dheeraj in forum Qwt
    Replies: 3
    Last Post: 21st April 2008, 11:54
  5. Replies: 6
    Last Post: 17th March 2006, 17:48

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.