QNetworkAccessManager



  • I've read that in QML the aplication creates as many objects of type QNetworkAccessManager it needs. So I have a few questions :
    1.Are the cookies share through all the instances of QNetworkAccessManager ?I want to login on a website ...
    2.How can XMLHttpRequest be used for sending POST/GET request?In Qt I created a QNetworkRequest and then used the manager to send it.Something like this :
    @QNetworkRequest request;
    //setam url-ul cererii
    request.setUrl(QUrl( "http://somesite.com"));

    request.setRawHeader( "User-Agent", this->loginGUI->lineEditUserAgent->text().toLatin1() );

    request.setHeader( QNetworkRequest::ContentTypeHeader,"application/x-www-form-urlencoded" );
    

    QUrl params;

    params.addEncodedQueryItem( "user", QUrl::toPercentEncoding(this->loginGUI->lineEditName->text()));
    params.addEncodedQueryItem( "password", QUrl::toPercentEncoding(this->loginGUI->lineEditPassword->text() ) );
    params.addEncodedQueryItem( "clear", QUrl::toPercentEncoding( "true" ) );
    QByteArray paramBytes = params.toString().mid( 1 ).toLatin1();
    paramBytes.replace( "/", "/" );

    QNetworkReply *reply=nam->post(request,paramBytes);
    connect( reply, SIGNAL( finished() ),
    SLOT(homepagesc()));@


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.