Light::Light()
{
    QObject::connect(&m_connection, SIGNAL(connected()), SLOT(on_connected()));
    QObject::connect(&m_connection, SIGNAL(error()), SLOT(on_error()));
    QObject::connect(&m_connection, SIGNAL(disconnected()), SLOT(on_disconnected()));
    QObject::connect(&m_connection, SIGNAL(readyRead()), SLOT(on_readyRead()));
}
ServerSocket::ServerSocket(int id)
{
    this->setSocketDescriptor(id);
    connect(this, SIGNAL(readyRead()),
            this, SLOT(on_readyRead()));
    connect(this, SIGNAL(disconnected()),
            this, SLOT(deleteLater()));
    connect(this, SIGNAL(disconnected()),
            this, SLOT(on_disconnected()));
}
示例#3
0
void TextTranslator::translate(QString word){
    QNetworkRequest request;
    request.setUrl(QUrl("http://fanyi.youdao.com/fanyiapi.do?keyfrom=www1gaicn"
                            "&key=636983872&type=data&doctype=xml&version=1.1&q="+word));
    *mReply=manager->get(request);
    cout<<"get reply";

    //after request
    //connect(&manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(on_replyFinished()));

    //after reply
    connect(*mReply,SIGNAL(readyRead()),this->mWindow,SLOT(on_readyRead()) );
}
示例#4
0
void Server::on_newConnection()
{
    socket = server->nextPendingConnection();
    if(socket->state() == QTcpSocket::ConnectedState)
    {
        printf("New connection established.\n");
    }
    else
        printf ("Something Wrong");

    connect(socket, SIGNAL(disconnected()),
            this, SLOT(on_disconnected()));
    connect(socket, SIGNAL(readyRead()),
            this, SLOT(on_readyRead()));
}