I'm having little problem here. I'm having troubles with signals & slots. I'll try to explain with pseudocode. So, here it goes.
I have main thread (mainwindow.cpp) where I'm creating new objects when new client connects.
mainwindow.h:
signals:
void changeText();
...
mainwindow.cpp:
connect(tcpserver, SIGNAL(changeText()), this, SIGNAL(changeText()));
...
MyClass *m = new MyClass(this);
connect(this, SIGNAL(changeText()), m, SLOT(changeText()));
I have also tcpserver class, which creates new QThread when client connects and connects both signals.
tcpserver.h:
signals:
void changeText();
protected:
void incomingConnection(int handle);
tcpserver.cpp:
void incomingConnection(int handle)
{
QTcpSocket *s = new QTcpSocket(this);
s->setSocketDescriptor(handle);
mythread *thread = new mythread(s, this);
connect(thread, SIGNAL(changeText()), this, SIGNAL(changeText()));
}
The problem is following: I have 3 objects, main thread, tcpserver class which inherits from QTcpServer, and the mythread class which inherits from QThread class.
When I'm creating new "mythread"-s from "tcpserver" and connecting signals, all signals from new threads are connected to "tcpserver"-s signals, so, e.g if 10 clients do something, all signals are sent to "tcpserver" which makes problem for me. I want to understand which signal should I connect to MyClass via QTread -> TcpServer -> MainWindow.
Sorry for my English, if you don't understand what I mean, I'll try to explain better.
Thank you.