Results 1 to 3 of 3

Thread: Terminate a QThread with an event loop

  1. #1
    Join Date
    Oct 2009
    Posts
    70

    Default Terminate a QThread with an event loop

    Hi,

    I've a main window with a separate thread ( with an event loop ) that copies file in a local disk.

    When I close my main window, i destroy the thread, but If the thread is copying a large file I can't stop it !!!

    I try with terminate(), quit(), exit(0), ... but the thread has the event loop and since it has complete the copy operation, it doesn't exit.

    Is it possible to do ?!?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Terminate a QThread with an event loop

    Can you show the relevant code?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    May 2010
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Terminate a QThread with an event loop

    Quote Originally Posted by paolom View Post
    I try with terminate()
    Thanks
    Did you check this:


    Termination can be explicitly enabled or disabled by calling QThread::setTerminationEnabled().
    You find it for example here:
    http://doc.qt.nokia.com/4.6/qthread.html#terminate

Similar Threads

  1. QThread event loop blocking the GUI
    By JoeMerchant in forum Qt Programming
    Replies: 4
    Last Post: 18th July 2009, 07:54
  2. QThread event loop seems blocked
    By eurodatar in forum Qt Programming
    Replies: 3
    Last Post: 6th May 2009, 16:50
  3. QThread::terminate () is not working!!!!!
    By biswajithit in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2008, 12:03
  4. Replies: 4
    Last Post: 27th July 2006, 11:13
  5. Workload in a QThread blocks main application's event loop ?
    By 0xBulbizarre in forum Qt Programming
    Replies: 14
    Last Post: 9th April 2006, 21:55

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.