Results 1 to 7 of 7

Thread: terminate a QThread from GUI

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2009
    Location
    phoenix, AZ
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default terminate a QThread from GUI

    Hello guys,

    I'm learning QThread with a simple application ... my thread start with a modified Run() function.

    in the run(), l activate a QDialog, do some stuff and wait with exec() for the user to click on QPushbutton "Keep" or "close"

    Qt Code:
    1. Thread_PulseMeas::Thread_PulseMeas(QObject *parent):
    2. QThread(parent)
    3. {
    4. diag_RealTimePlot = new QDialog;
    5. ui_RealTimePlot.setupUi(diag_RealTimePlot);
    6. diag_RealTimePlot->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | Qt::WindowMaximizeButtonHint);
    7. connect(ui_RealTimePlot.Close, SIGNAL(clicked()), this, SLOT(Close()));
    8. connect(ui_RealTimePlot.Add, SIGNAL(clicked()), this, SLOT(Add()));
    9. };
    10.  
    11. void Thread_PulseMeas::run( Pulse_Meas *PulseMeas)
    12. {
    13. diag_RealTimePlot->show();
    14. Pulse_measure(PulseMeas);
    15. exec();
    16.  
    17. }
    18.  
    19. void Thread_PulseMeas::Close()
    20. {
    21. SetKeep(false);
    22. diag_RealTimePlot->close();
    23. exit();
    24. }
    25. void Thread_PulseMeas::Add()
    26. {
    27. SetKeep(true);
    28. diag_RealTimePlot->close();
    29. exit();
    30. }
    To copy to clipboard, switch view to plain text mode 
    when l click "keep" or "close", the QDIALOG is closed but the thread is not terminated ....

    am l missing something there ?

    regards,

    Michael
    Last edited by wysota; 24th July 2010 at 21:41. Reason: missing [code] tags

Similar Threads

  1. Best way to terminate a copy thread?
    By scarleton in forum Newbie
    Replies: 1
    Last Post: 13th July 2010, 05:43
  2. Terminate a QThread with an event loop
    By paolom in forum Qt Programming
    Replies: 2
    Last Post: 12th May 2010, 11:53
  3. QThread::terminate () is not working!!!!!
    By biswajithit in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2008, 12:03
  4. How to destroy or terminate a thread ?
    By probine in forum Qt Programming
    Replies: 3
    Last Post: 26th December 2006, 16:44
  5. Replies: 4
    Last Post: 27th July 2006, 11:13

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.