class SocketContainer {
private:
QTcpSocket* m_sockets[10];
public:
SocketContainer() {
for(int i = 0; i < 10; i++)
connect(m_sockets[i], SIGNAL(readyRead()), this, SLOT(onNewData()));
}
private slots:
onNewData();
}
如何知道readyRead
中哪个套接字onNewData()
?
答案 0 :(得分:2)
您可以使用发件人作为 Kourosh 建议,或者QSignalMapper更符合您的需求。
答案 1 :(得分:1)
虽然已经回答了,但这里有一个片段:
QObject *sigsender=sender();
if (sigsender) {
DEBUG << " signal call objn: " << sigsender->objectName() << " clasn: " << sigsender->metaObject()->className();
} else {
DEBUG << " direct call";
}