void threadForm::keyPressEvent ( QKeyEvent * event){...if(event->key == Qt::Key_1) { thread->quit(); thread->wait(); event->accept(); }}void threadForm::mouseDoubleClickEvent ( QMouseEvent * event ){ ... if(thread->isRunning()) { thread->quit(); thread->wait(); } thread->start; event->accept;}