Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    May 2009

    qt http request problem

    Hello I am using Carbide C++ 2.0.2 with Nokia N97 SDK 1.0. The following code works well with the Emulator. However when I try on device debug configuration the status code in "httpFinished" method returns empty. I can not get the text of requsted url. At the time of on device debug, the Nokia N97 is already connected to the access point at home (my wireless modem) and the browser works fine. I am using self signing configuration (self sign sis file).

    Although my device is connected to the accesspoint (browser is working fine), Do I need to set the access point in the code? If not, what can be the problem with this http request?

    Here is the header file:

    #ifndef QTINTERNET_H
    #define QTINTERNET_H
    #include <QtGui/QMainWindow>
    #include "ui_QTInternet.h"
    #include <QMessageBox>
    #include <qtimer.h>
    #include <stdlib.h>
    #include <QtNetwork/qhttp.h>
    #include <QtNetwork/qnetworkaccessmanager.h>
    #include <QtNetwork/qnetworkrequest.h>
    #include <QtNetwork/qnetworkreply.h>
    #include <qurl.h>
    #include <qplaintextedit.h>
    class QTInternet : public QMainWindow
    	QTInternet(QWidget *parent = 0);
    private slots:
    	void fetch_clicked();
    	void httpFinished(QNetworkReply* reply);
        Ui::QTInternetClass ui;
        QString urlArray[3];
        QHttp *myHttp;
        QNetworkAccessManager*  netMan;
    #endif // QTINTERNET_H
    Here is the cpp file:
    #include "QTInternet.h"
    QTInternet::QTInternet(QWidget *parent)
        : QMainWindow(parent)
    	connect(ui.fetchbutton,SIGNAL(clicked()), this, SLOT(fetch_clicked()));
    	netMan = new QNetworkAccessManager(this);
    	QObject::connect(netMan, SIGNAL(finished(QNetworkReply*)),this, SLOT(httpFinished(QNetworkReply*)));
    void QTInternet::httpFinished(QNetworkReply* reply){
    // Reading attributes of the reply
        QVariant statusCodeV = 
    	//int randomSayi = rand()%3;
    	QMessageBox msgBox;
    	//QString number(statusCodeV.toInt());
    	//int ret = msgBox.exec();
    	QVariant tempQ = QVariant(statusCodeV.toString().length());
    	int ret = msgBox.exec();
        // "200 OK" received?
        if (statusCodeV.toInt()==200)
            // TODO: read data from QNetworkReply
            int ret = msgBox.exec();
            QByteArray bytes = reply->readAll();  // bytes
            const QString string(bytes); // string
        // Some http error or redirect
            // TODO: 
            int ret = msgBox.exec();
        delete reply;
    void QTInternet::fetch_clicked(){
    	QMessageBox msgBox;
    	int ret = msgBox.exec();
    	QUrl url("http://www.google.com");
    	//QUrl url(ui.plEdit->text());
    	QNetworkReply* reply = netMan->get(QNetworkRequest(url));
    Last edited by ltomuta; 2009-10-11 at 21:05. Reason: Made code section legible

  2. #2
    Regular Contributor
    Join Date
    May 2009

    Re: qt http request problem

    my qt version is also qt for S60 4.5.2 tower.

  3. #3
    Regular Contributor
    Join Date
    May 2009

    Re: qt http request problem [Solved]

    Solved after adding

    symbian {
    TARGET.CAPABILITY = NetworkServices

    to the .pro file..

  4. #4
    Registered User
    Join Date
    Dec 2010

    Re: qt http request problem

    i just found this code and it works well. Thanks for this.
    My question now, is it possible that the app recognizes the url and underlines so that the user just can push/click on it and the browser will show the website?

    thanks for replies.


Similar Threads

  1. HTTP Connection behaviour when 3G connection is lost (or being lost)
    By TwmD in forum Mobile Java Networking & Messaging & Security
    Replies: 6
    Last Post: 2010-01-27, 12:36
  2. how to know that network connection breaks during HTTP request
    By Ajmal in forum Symbian Networking & Messaging (Closed)
    Replies: 5
    Last Post: 2008-09-18, 11:40
  3. Simple http request
    By Christophe.A in forum Symbian Networking & Messaging (Closed)
    Replies: 8
    Last Post: 2008-06-11, 16:42
  4. Problem with HTTP POST
    By thathoo in forum Mobile Java General
    Replies: 2
    Last Post: 2006-12-18, 18:23
  5. Series 40 phones HTTP POST problem
    By jessicay in forum Mobile Java Networking & Messaging & Security
    Replies: 0
    Last Post: 2004-06-23, 01:01

Posting Permissions

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