Qt - 捕获来自多个类的发射信号

时间:2012-12-26 12:58:32

标签: qt signals-slots emit

我正在开发一个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)));

我错过了什么?

提前致谢!

0 个答案:

没有答案