+ Reply to Thread
Results 1 to 2 of 2

Thread: QTimer at 50Hz on Linux - High CPU Usage

  1. #1
    Join Date
    Jan 2018
    Posts
    3
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default QTimer at 50Hz on Linux - High CPU Usage

    Hello,
    I am using QT 5.8

    On Windows I have no ploblems.
    On Fedora 25 Using a qTimer set at 50 hz, the CPU usage rises to 90%.
    If I reduce the frequency of the qTimer the CPU usage decreases considerably.

    Qt Code:
    1. QTimer* m_timer; // in file .h
    2.  
    3. // in file .cpp
    4.  
    5. m_timer= new QTimer();
    6. int interval = (1 / 50) * 1000;
    7.  
    8. m_timer->start(interval);
    9.  
    10. connect(m_timer SIGNAL(timeout()),
    11. this, SLOT(slotRead()));
    To copy to clipboard, switch view to plain text mode 

    Can you give me some suggestions?

    Thanks in advance!
    Best Regards!

  2. #2
    Join Date
    Jul 2008
    Posts
    355
    Thanks
    9
    Thanked 44 Times in 42 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer at 50Hz on Linux - High CPU Usage

    Quote Originally Posted by Elisabetta View Post
    Qt Code:
    1. int interval = (1 / 50) * 1000;
    To copy to clipboard, switch view to plain text mode 
    Hi, "interval" here becomes zero because 1/50 is done using integers. This is probably not what you want (or not what you actually do...).

    Ginsengelf

+ Reply to Thread

Similar Threads

  1. QTimer Usage in C++ Unix / Windows
    By rcanerA in forum Newbie
    Replies: 4
    Last Post: 15th May 2017, 05:53
  2. PyQt4 app : high CPU usage from python and Xorg
    By tipote in forum Qt Programming
    Replies: 3
    Last Post: 30th January 2012, 17:50
  3. High cpu usage in custom QItemDelegate::paint
    By rsilva in forum Qt Programming
    Replies: 1
    Last Post: 17th May 2011, 22:52
  4. High CPU Usage in Drawing
    By lordhippo in forum Qt Programming
    Replies: 15
    Last Post: 21st May 2010, 22:48
  5. Very high CPU usage with QTableView and MVC
    By montylee in forum Qt Programming
    Replies: 7
    Last Post: 24th March 2009, 06:14

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