Results 1 to 2 of 2

Thread: Let QThread delete itself with deleteLater();

  1. #1
    Join Date
    May 2009
    Posts
    21
    Thanks
    4
    Thanked 2 Times in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Let QThread delete itself with deleteLater();

    Hi,

    is it okay to let a QThread delete itself when it is finished by calling deleteLater()?

    Qt Code:
    1. MyThread::MyThread()
    2. : QThread() {
    3. QObject::connect(this,
    4. SIGNAL(finished()),
    5. this,
    6. SLOT(deleteLater()));
    7. }
    To copy to clipboard, switch view to plain text mode 

    It seems to work but could there be any side effects?

    Thanks

    Lodorot

  2. #2
    Join Date
    Jan 2006
    Location
    Sta. Eugènia de Berga (Vic - Barcelona - Spain)
    Posts
    869
    Thanks
    70
    Thanked 59 Times in 57 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Let QThread delete itself with deleteLater();

    Hi,

    I think that ther can't be side effects due delete will be executed in the event loop.
    Òscar Llarch i Galán

Similar Threads

  1. To use or not to use: deleteLater()
    By codeslicer in forum Qt Programming
    Replies: 11
    Last Post: 11th July 2009, 21:43
  2. QThread new and delete
    By babu198649 in forum Qt Programming
    Replies: 3
    Last Post: 18th April 2009, 14:22
  3. Replies: 4
    Last Post: 19th February 2009, 11:10
  4. QT deleteLater again.
    By bunjee in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2008, 22:36
  5. Qt Deletelater
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 8th January 2008, 16:58

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.