parVF->exit()
...TestThread::run(){while(true){полезная_нагрузка_дабы_не_убило_оптимизацией;}}...
...TestThread::run(){полезная_нагрузка;exec();}...
// widget.h#ifndef WIDGET_H#define WIDGET_H#include <QWidget>#include <QThread>class Thread: public QThread{public: Thread() { setTerminationEnabled(1); } void run() { int i; while(1) i++; }};class Widget : public QWidget{Q_OBJECTpublic: explicit Widget(QWidget *parent = 0);public slots: void terminateThread();private: Thread *thr;};#endif // WIDGET_H// widget.cpp#include <QPushButton>#include "widget.h"Widget::Widget(QWidget *parent) :QWidget(parent){ QPushButton *btn=new QPushButton(this); thr = new Thread(); thr->start(); connect(btn,SIGNAL(clicked()), this,SLOT(terminateThread()));}void Widget::terminateThread(){ thr->terminate(); thr->wait();}// main.cpp#include <QApplication>#include "widget.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); Widget w; w.show(); return a.exec();}
Qt::HANDLE currentThread ()