Results 1 to 2 of 2

Thread: QTimer lifetime

  1. #1
    Join Date
    Aug 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default QTimer lifetime

    Hi all,

    I've got a single-shot QTimer which is allocated like:
    Qt Code:
    1. QTimer* timer = new QTimer(this);
    2. timer->setInterval(...);
    3. timer->setSingleShot(true);
    4. timer->start();
    To copy to clipboard, switch view to plain text mode 

    I wonder whether the timer gets dealloced when it fires or when the current object gets deallocated. The reason I am asking is because I allocate many of these timers throughout the lifetime of the object.

    Thanks,
    M
    Last edited by jpn; 6th August 2008 at 21:36. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTimer lifetime

    No, it doesn't. But you can connect it to its own deleteLater() to make it self destruct safely.

Similar Threads

  1. Replies: 8
    Last Post: 27th March 2013, 12:51
  2. Extending QTimer()
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 7th August 2009, 02:59
  3. QThread/QObject and QTimer
    By swiety in forum Qt Programming
    Replies: 2
    Last Post: 25th January 2008, 09:37
  4. Replies: 5
    Last Post: 6th March 2007, 06:34
  5. QTimer problem ... it runs but never triggs
    By yellowmat in forum Newbie
    Replies: 4
    Last Post: 4th July 2006, 13:54

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.