Results 1 to 4 of 4

Thread: HTTP Connection establishment problem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2013
    Posts
    50
    Thanks
    5

    Default HTTP Connection establishment problem

    Hello, I am developing app on BB 10 using C++ and I have this code from QT web site where in the end I want to establish HTTP connection with server and get JSON
    data. But first here is the code where I also try to register slot and send get request.

    // Creates the network access manager and connects a custom slot to its
    // finished signal. Checks the return value for errors.
    QNetworkAccessManager *manager = new QNetworkAccessManager(this);
    bool res = connect(manager, SIGNAL(finished(QNetworkReply*)),
    this, SLOT(replyFinished(QNetworkReply*)));

    Q_ASSERT(res);

    // Indicate that the variable res isn't used in the rest of the app, to prevent
    // a compiler warning
    Q_UNUSED(res);


    manager->get(QNetworkRequest(QUrl("http://qt.nokia.com")));

    The problem is that during the debug, the "res" variable is False, after the "connect" line
    gets executed. Is this the correct behaviour? thanks.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: HTTP Connection establishment problem

    Have a look at the console. If the connection could not be established there are usually messages at the output. Just a wild guess: have the "this"-class the Q_OBJECT macro?

  3. #3
    Join Date
    Feb 2013
    Posts
    50
    Thanks
    5

    Default Re: HTTP Connection establishment problem

    Screen Shot 2013-02-06 at 11.39.06 AM.jpg This is the screenshot, I am not sure it is helpful, quite strangely it mentions some of my two other projects (SampleApp1 and InjectCppIntoXml). PS. Yes, "this" has Q_OBJECT macro.


    Added after 33 minutes:


    OK I managed to get some output using slog2info. This is what I get at some point during debug: "Feb 02 03:49:59.658 com.example.JSONSample.testDev__JSONSampled2265543 .1154138249
    default 9000 Object::connect: No such slot JSONSample::replyFinished(QNetworkReply*) in ../src/JSONSample.cpp:36". Why do I get this message?? I have replyFinished defined both in header and cpp files.


    Added after 5 minutes:


    I think I found a solution, I guess I had to add following line: "public slots:" to the header file.


    public slots:

    void replyFinished(QNetworkReply* reply);
    Last edited by ggdev001; 6th February 2013 at 08:21.

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: HTTP Connection establishment problem

    hmm, that would have been my second guess after Q_OBJECT...

Similar Threads

  1. Creating a HTTP connection
    By Momergil in forum Qt Programming
    Replies: 4
    Last Post: 4th January 2013, 12:47
  2. Problem on connection establishment with QTcpSocket
    By Mascetti1987 in forum Newbie
    Replies: 1
    Last Post: 23rd November 2011, 09:30
  3. Http connection in Qt
    By sabbu in forum Newbie
    Replies: 4
    Last Post: 27th May 2011, 11:54
  4. http connection
    By bhogasena in forum Qt Programming
    Replies: 12
    Last Post: 25th February 2009, 11:32
  5. http Problem
    By bhogasena in forum Qt Programming
    Replies: 1
    Last Post: 25th February 2009, 06:02

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
  •  
Qt is a trademark of The Qt Company.