Problem is that you are doing that wrong!
{
Q_OBJECT
public:
public slots:
void tick();
};
{
connect(t, SIGNAL(timeout()), this, SLOT(tick()));
}
void TestClass::tick()
{
qDebug() << currentThreadId() << "tick()";
}
// and somewhere
TestClass *object = new TestClass(); // can't pass parent!!!!!!
object->moveToThread(thread);
thread->start();
....
delete object;
thread->WaitFor();
// delete thread;
class TestClass : QObject
{
Q_OBJECT
public:
TestClass(QObject *parent=0);
public slots:
void tick();
};
TestClass::TestClass(QObject *parent) : QObject(parent)
{
QTimer *t = new QTimer(this);
connect(t, SIGNAL(timeout()), this, SLOT(tick()));
}
void TestClass::tick()
{
qDebug() << currentThreadId() << "tick()";
}
// and somewhere
QThread *thread = new QThread(something);
TestClass *object = new TestClass(); // can't pass parent!!!!!!
object->moveToThread(thread);
thread->start();
....
delete object;
thread->WaitFor();
// delete thread;
To copy to clipboard, switch view to plain text mode
Bookmarks