Results 1 to 2 of 2

Thread: createRequest does not finish

  1. #1
    Join Date
    Apr 2013
    Posts
    65
    Thanks
    4
    Thanked 3 Times in 1 Post
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Question createRequest does not finish

    I can not do QNetworkAccessManager::createRequest finalize request. I tried
    Qt Code:
    1. finished(QNetworkRequest)
    To copy to clipboard, switch view to plain text mode 
    , but nothing happens, see how was the WebInspector:

    7IA6s.png

    The request is pending and never ends.

    What am I doing wrong?

    My code:

    Qt Code:
    1. QNetworkReply * myNAM::createRequest(Operation op, const QNetworkRequest &request, QIODevice *outgoingData){
    2. QNetworkAccessManager *n = new QNetworkAccessManager();
    3.  
    4. QNetworkRequest req(request.url());
    5.  
    6. const QList<QByteArray>a = request.rawHeaderList();
    7. int j = a.length();
    8. int i=0;
    9.  
    10. for(;i<j;++i){
    11. req.setRawHeader(a[i],request.rawHeader(a[i]));
    12. }
    13.  
    14. QList<QNetworkCookie> cookies = CookiesGlobals->cookiesForUrl(request.url());
    15. n->cookieJar()->setCookiesFromUrl(cookies,request.url());
    16.  
    17. QNetworkReply *p;
    18. if(op==PostOperation) {
    19. const QByteArray data = outgoingData->readAll();
    20. p = n->post(req, data);
    21. } eles {
    22. p = n->get(req);
    23. }
    24.  
    25. QEventLoop loop;
    26. connect(p, SIGNAL(finished()), &loop, SLOT(quit()));
    27. loop.exec();
    28.  
    29. QVariant statusCode = p->attribute(QNetworkRequest::HttpStatusCodeAttribute);
    30. if (statusCode.isValid()){
    31. int status = statusCode.toInt();
    32. qDebug() << "FB: " status;
    33. } else {
    34. qDebug() << "FB: statusCode isInvalid";
    35. }
    36. finished(p);
    37. return p;
    38. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: createRequest does not finish

    createRequest() serves the purpose of (as the name implies) creating the request, not executing it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. A slot cause program to finish unexpectedly
    By SIFE in forum Qt Programming
    Replies: 3
    Last Post: 7th July 2012, 12:08
  2. Link Error and Unexpected Finish
    By decoy in forum Newbie
    Replies: 1
    Last Post: 14th June 2012, 01:43
  3. simple console application does ot finish
    By szisziszilvi in forum Newbie
    Replies: 4
    Last Post: 9th January 2012, 11:22
  4. Wait for a function to finish
    By fitzy in forum General Programming
    Replies: 3
    Last Post: 26th October 2009, 18:20
  5. Finish of PaintEvent
    By jimfan in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 07:50

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.