This doesn't work:
Thread thread;
connect(&thread, SIGNAL(counterValueChanged(int)), ...);
thread.start();
thread.moveObjectsToThread();
Thread thread;
connect(&thread, SIGNAL(counterValueChanged(int)), ...);
thread.start();
thread.moveObjectsToThread();
To copy to clipboard, switch view to plain text mode
No signals emiited at all and iwarning in console is:
QThread: Destroyed while thread is still running
But this works fine:
Thread *thread;
connect(thread, SIGNAL(counterValueChanged(int)), ...);
thread->start();
thread->moveObjectsToThread();
Thread *thread;
connect(thread, SIGNAL(counterValueChanged(int)), ...);
thread->start();
thread->moveObjectsToThread();
To copy to clipboard, switch view to plain text mode
Thread is created and started in main window constructor. In the first case - QThread object is destroyed without stopping thread. So, the thread works, but without any control ("Ping" commands are printed as weel). Why?
Bookmarks