×

Discussion Board

Results 1 to 6 of 6
  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Question Qt Symbian PHP response.

    Hi all, I'm really new with this Qt thing... And I'm trying to do some stuff that involve http comm... now.. In Java Micro Edition (J2ME) it's really easy to request some http connection with an url having a php variable and then the server responded with that same variable I just sent. How should I do that here in Qt ?

    I've only managed to code this (even tough I haven't test it...yet)

    Code:
    void MainWindow::on_pushButton_clicked()
    {
        ui->lineEdit->setText("Request Sended");
        QUrl url;
        QNetworkRequest qNetReq;
        url.setUrl("http://somedomain.com/script.php?v=aaa");
        qNetReq.setUrl(url);
        
    
    }
    If I want to get 'aaa' back from the server and then show it in a lineEdit object... what's missing? probably everything... thanks in advance...

  2. #2
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Qt Symbian PHP response.

    Some code I took from Qt documentation:
    Code:
    void MainWindow::on_pushButton_clicked()
    {
        ui->lineEdit->setText("Request Sent");
        
        QNetworkAccessManager *manager = new QNetworkAccessManager(this);
        connect(manager, SIGNAL(finished(QNetworkReply*)),
                this, SLOT(replyFinished(QNetworkReply*)));
    
        manager->get(QNetworkRequest(QUrl("http://somedomain.com/script.php?v=aaa")));
    }
    P.S. Apparently it doesn't make sense to create access manager in the slot of clicked signal,
    move it to appropriate place.

  3. #3
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: Qt Symbian PHP response.

    Quote Originally Posted by divanov View Post
    Some code I took from Qt documentation:
    P.S. Apparently it doesn't make sense to create access manager in the slot of clicked signal,
    move it to appropriate place.
    Right, because the object is created on the stack and is thus destroyed as soon as you leave the enclosing scope {}.

  4. #4
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Qt Symbian PHP response.

    Quote Originally Posted by axeljaeger View Post
    Right, because the object is created on the stack and is thus destroyed as soon as you leave the enclosing scope {}.
    The code uses operator new to allocate it from heap.

  5. #5
    Regular Contributor
    Join Date
    Mar 2009
    Posts
    430

    Re: Qt Symbian PHP response.

    You are right, I was screwing up between the first and the second example. So new explaination:

    Everytime the slot is executed, a new instance of the QNetworkAccessManager is created and thus, a lot of memory is used and only freed if you restart the application.
    Last edited by axeljaeger; 2010-02-01 at 10:53.

  6. #6
    Registered User
    Join Date
    Nov 2009
    Posts
    27

    Re: Qt Symbian PHP response.

    Hey thanks a lot to everyone.. I'll try those lines, and then I'll let you know.. thanks for your help to all of you...

Similar Threads

  1. Symbian QT
    By ramyanair in forum News and Announcements
    Replies: 3
    Last Post: 2009-08-14, 18:30

Posting Permissions

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