×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    231

    Question QNetworkAccessManager and UnknownNetworkError

    Hi all,

    I always get "Network session error" value in network_reply->errorString() and UnknownNetworkError value in network_reply->error().

    I have this code:

    Code:
    	nam = new QNetworkAccessManager(this);
    	connect(nam, SIGNAL(finished(QNetworkReply*)), this, SLOT(network_reply_finished(QNetworkReply*)));
    
    ...
    
    	QUrl url("http://discussion.forum.nokia.com");
    	nam->get(QNetworkRequest(url));
    
    ...
    
    void MyWindow::network_reply_finished(QNetworkReply* network_reply)
    {
        QVariant statusCodeV;
        // Reading attributes of the reply
        // e.g., the HTTP status code
        statusCodeV = network_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(&conversion_status);
     
        // if no error received
        if (network_reply->error() == QNetworkReply::NoError)
        	{
            QByteArray data = network_reply->readAll();
            ui.listWidget->addItem(QString(data));
        	}
        // Some http error received
        else //handle errors here
        	{
        	ui.listWidget->addItem("Error: " + network_reply->errorString());
        	}
        // We receive ownership of the reply object
        // and therefore need to handle deletion.
        delete network_reply;
    }
    What is wrong?

    Regards.

  2. #2
    Regular Contributor
    Join Date
    Aug 2008
    Posts
    95

    Re: QNetworkAccessManager and UnknownNetworkError

    Have you
    TARGET.CAPABILITY +=NetworkServices

    in your .pro ?

    Otherwise, have you tried to connect to url on a pc using a browser (to see the reply) ?

  3. #3
    Regular Contributor
    Join Date
    Feb 2009
    Posts
    231

    Re: QNetworkAccessManager and UnknownNetworkError

    Hi,

    I have added:

    Code:
    TARGET.CAPABILITY +=NetworkServices
    and it works.

    Regards.

Similar Threads

  1. Replies: 4
    Last Post: 2010-11-05, 17:29
  2. Replies: 3
    Last Post: 2010-09-28, 18:43
  3. QNetworkAccessManager and Qthread
    By Fillinger in forum Qt
    Replies: 12
    Last Post: 2010-09-25, 21:18

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •