Results 1 to 5 of 5

Thread: Replacement for QTimer?

  1. #1
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Replacement for QTimer?

    I have a video player that I made using a custom class for dealing with extracting frames from the video (in other words, I'm not using Phonon) and I'm drawing the frames on a QLabel during video playback which I control using QTimer with setInterval. I see that QTimer's setInterval is not sufficient for accurate video playback speed (I set it to 33 ms but the slot is being called ever 46 ms). Is there a recommended method I should use to get accurate playback speed? If my code can't keep up, its okay to skip a frame or something but I need the total time to play the video to be equal to the total time of the video and I assume that messing around with guesses for setInterval until I get it right is not the way to go, especially when this program will be running on different machines and different processes may be occuring during playback (for instance, drawing additional items on the frame). How can I get accurate playback speed?

    I greatly appreciate suggestions!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Replacement for QTimer?

    What Qt version are you using? What Windows version are you on? As far as I know recent Qt versions shouldn't have problems with small intervals on Windows.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Replacement for QTimer?

    QTimer depends on the program returning to the event loop for signal dispatch so if the program takes 40ms to return to the loop then the timer will be delayed. Are you sure the program returns to the event loop often enough that the timer is not being delayed?

  4. #4
    Join Date
    Oct 2011
    Location
    CHINA
    Posts
    8
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Replacement for QTimer?

    Maybe u have the same problem with me , this may help http://www.qtcentre.org/wiki/index.p...GUI_Responsive

  5. #5
    Join Date
    Oct 2010
    Posts
    13
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Replacement for QTimer?

    I didn't notice these responses earlier (I thought I was set up for notifications), anyway, I decided to dynamically adjust the interval based on how long it was taking between calls to the slot and that's been working pretty well. I'm definitely doing some heavy processing in my slot that can bog down the program and sometimes (when drawing a dynamic heat map, for instance) it just can't keep up, but most of the time, it just has to decrease the interval a little bit.

    I'm looking at this article that hoffen suggested now, it looks interesting, thanks. Maybe I can improve my timing in a way that's less of a hack!

Similar Threads

  1. Using QTabBar as QTabWidget replacement
    By invictus in forum Qt Programming
    Replies: 0
    Last Post: 16th August 2008, 02:57
  2. Replacement for CMapStringToPtr
    By rajeshs in forum Newbie
    Replies: 3
    Last Post: 21st December 2007, 13:25
  3. Replacement for MESSAGE_MAP()
    By krishbhala in forum Qt Programming
    Replies: 2
    Last Post: 4th December 2007, 16:20
  4. Console replacement
    By aegis in forum Qt Programming
    Replies: 14
    Last Post: 3rd April 2007, 01:38
  5. Replacement of Images
    By merry in forum Qt Programming
    Replies: 5
    Last Post: 1st March 2007, 11:16

Tags for this Thread

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.