[Interest] Thread stopped, signal ignored

Etienne Sandré-Chardonnal etienne.sandre at m4x.org
Wed Mar 20 17:53:14 CET 2013


Dear all,

I'm currently using a QThread with a QObject pushed in it using
moveToThread. The QObject is basically a network server of class
NetworkServer, it has a close() slot that closes the QTcpServer and
outputs a "Port closed" message to the console.
In my main thread, I have a signal "closeServer()" connected to the
"close()" port of the NetworkServer


I am doing this:

QThread * thread= new QThread();
MyObject * myObject = new MyObject ();
myObject->moveToThread(thread);

connect(this, SIGNAL(testMessage()), myObject, SLOT(message()));
connect(thread, SIGNAL(finished()), myObject, SLOT(deleteLater()));

thread->start();


...... later on ......



emit testMessage();
serverThread->quit();
serverThread->wait();



Finally, the slot MyObject::message() is never executed (no console output)
I thought that the slot execution would be queued and executed before
the thread quits, do you know why this doesn't work?

My example

Thanks,

Etienne



More information about the Interest mailing list