#include #include "thread.h" Thread::Thread(QObject * parent) : QThread(parent), m_iteration(0) { } void Thread::run() { QStateMachine machine; QState* state = new QState();//(machine); machine.addState(state); machine.setInitialState(state); connect(state, SIGNAL(entered()), this, SLOT( entry() ), Qt::DirectConnection); state->addTransition(this, SIGNAL(transition()), state); machine.start(); QEventLoop loop; loop.exec(); } void Thread::entry() { QThread::sleep(1); if (m_iteration++ > 2) { qDebug()<<"bug"; m_iteration = 0; emit transition(); throw QString("qwerty"); } emit transition(); }