Results 1 to 5 of 5

Thread: QTimer and QThread

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Sep 2006
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTimer and QThread

    Hello,
    I think You can improve your run() function in the following way:

    Qt Code:
    1. void Logger::run()
    2. {
    3. QTimer timer;
    4. timer.setInterval(updateIntervalSeconds*1000);
    5. connect(&timer, SIGNAL(timeout()), this, SLOT(doJob()));
    6.  
    7. timer.start();
    8.  
    9. exec();
    10. }
    To copy to clipboard, switch view to plain text mode 

    I think it is better to create QTimer object on the stack. This object will be destroyed automatically when the run() function finishes. When You call exec() - evet loop is started at this point.

    Br,
    Poter
    Last edited by jacek; 20th September 2006 at 16:49. Reason: missing [code] tags

Similar Threads

  1. QThread
    By TheKedge in forum Qt Programming
    Replies: 8
    Last Post: 25th August 2006, 11:29
  2. Qthread n QTimer Problem
    By quickNitin in forum Qt Programming
    Replies: 5
    Last Post: 8th June 2006, 15:12
  3. Replies: 6
    Last Post: 17th March 2006, 18: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
  •  
Qt is a trademark of The Qt Company.