Results 1 to 6 of 6

Thread: Qt5 / C++ - Time delay, Windows 10 - Windows 7

  1. #1
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Qt5 / C++ - Time delay, Windows 10 - Windows 7

    QT 5.6.0

    Hello,

    I'm using a time delay in my program, and noticed a drastic difference
    in execution time between Windows 10 and Windows 7 (Dual boot system).
    The time delay does not have to accurate (Animation).

    Typical output:-
    15156535 Windows 10
    1379155 Windows 7

    Its probably the processEvents, I would like the system to be responsive.
    Is there a better way to achive similar results between the two systems?

    Regards

    Qt Code:
    1. void myProg:tDelay(int milliSecs)
    2. {
    3. QElapsedTimer timer;
    4. timer.restart();
    5. qint64 nanoSec;
    6. timer.start();
    7.  
    8. QTime dieTime = QTime::currentTime().addMSecs(milliSecs);
    9. while (QTime::currentTime() < dieTime)
    10. QCoreApplication::processEvents(QEventLoop::AllEvents, 1);
    11.  
    12. nanoSec = timer.nsecsElapsed();
    13. qDebug() << nanoSec;
    14. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt5 / C++ - Time delay, Windows 10 - Windows 7

    QTime::currentTime can be a very costly call.

    But maybe you can explain what you are actually trying to do?
    That doesn't look like anything that would appear in a real program.

    Cheers,
    _

  3. #3
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt5 / C++ - Time delay, Windows 10 - Windows 7

    Hello anda_skoa,

    Thanks for your reply.
    I'm doing nothing more than moving a QLabel around a form, with the delay between moves.

    Regards

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt5 / C++ - Time delay, Windows 10 - Windows 7

    Hmm.

    Wouldn't that be easier with a QPropertyAnimation?

    Cheers,
    _

  5. The following user says thank you to anda_skoa for this useful post:

    jimbo (2nd June 2016)

  6. #5
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Qt5 / C++ - Time delay, Windows 10 - Windows 7

    If You really need this method do it like this :
    Qt Code:
    1. void myProg:tDelay(int milliSecs)
    2. {
    3. QElapsedTimer timer;
    4. timer.restart();
    5. qint64 nanoSec;
    6. timer.start();
    7. QEventLoop loop;
    8. QTimer::singleShot( milliSecs,&loop,SLOT(quit()) );
    9. loop.exec();
    10.  
    11. nanoSec = timer.nsecsElapsed();
    12. qDebug() << nanoSec;
    13. }
    To copy to clipboard, switch view to plain text mode 

  7. The following user says thank you to Lesiok for this useful post:

    jimbo (2nd June 2016)

  8. #6
    Join Date
    Oct 2006
    Posts
    105
    Thanks
    13
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt5 / C++ - Time delay, Windows 10 - Windows 7

    Helo,

    Thanks to anda_skoa and Lesiok.

    Wouldn't that be easier with a QPropertyAnimation?
    Yes, some nice effects.

    If You really need this method do it like this :
    Gives a simiar result between the two systems.

    Regards

Similar Threads

  1. Replies: 1
    Last Post: 15th September 2015, 10:10
  2. Replies: 0
    Last Post: 10th October 2013, 07:04
  3. Delay in Between loading windows In Qt
    By vishnu717 in forum Newbie
    Replies: 1
    Last Post: 5th July 2011, 09:07
  4. Problem with first time QDevelop in windows
    By RefinedCode in forum Qt Tools
    Replies: 1
    Last Post: 14th June 2010, 08:11
  5. Qt3 and Qt4 at the same time [Windows]
    By Opilki_Inside in forum Installation and Deployment
    Replies: 5
    Last Post: 28th March 2006, 21:47

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.