Qt 支持信号与信号的传输
在helloWorld类中建立:
server = new DaemonTcpServer(this);
connect(server, SIGNAL(newRequest(DaemonTcpRequest*, DaemonTcpResponse*)),
this, SLOT(handleRequest(DaemonTcpRequest*, DaemonTcpResponse*)));
在DaemonTcpServer类中建立:
DaemonTcpConnection *connection = new DaemonTcpConnection(m_tcpServer->nextPendingConnection(), this);
connect(connection, SIGNAL(newRequest(DaemonTcpRequest *, DaemonTcpResponse *)),
this, SIGNAL(newRequest(DaemonTcpRequest *, DaemonTcpResponse *)));
这样QTcpSocket触发
connect(socket, SIGNAL(readyRead()), this, SLOT(parseRequest()));
的是时候,
在DaemonTcpConnection中调用:
Q_EMIT this->newRequest(this->m_request, response);
DaemonTcpConnection.