0

我正在开发一个 TCP 服务器应用程序。我有 newDataReceived 插槽,我在其中发出一个信号,如下所示:

void myclass::newDataReceived()
{

    char data_received[1024] = {0};
    client->read(data_received, client->bytesAvailable());
    QString msg = data_received;
    QString client_ip = client->peerAddress().toString();

    emit dataReceived(msg,client_ip);
}

我已经从 MainWindow 捕捉到信号,没有问题。但是,我有另一个类是 QThread,我希望这个类也能捕捉到这个信号。但它不这样做。我将信号连接到我的插槽,例如,

srv_thread = new myclass();
connect(srv_thread, SIGNAL(dataReceived(QString,QString)), this, SLOT(incoming_message(QString,QString)));

我错过了什么?

提前致谢!

4

0 回答 0