×

Discussion Board

Results 1 to 9 of 9
  1. #1
    Registered User
    Join Date
    Jan 2009
    Location
    ભારત->ગુજરાત->ભાવનગર
    Posts
    279

    Question Storing data from Network reply

    hi
    i am working on the given below code
    Code:
    #include "widget.h"
    #include "ui_widget.h"
    
    Widget::Widget(QWidget *parent) :
        QWidget(parent)
    {
        QString str="http://www.youtube.com/watch?v=qybUFnY7Y8w";
        manager=new QNetworkAccessManager(this);
    
         QNetworkRequest request;
         request.setUrl(QUrl(str));
         request.setRawHeader("User-Agent", "MyOwnBrowser 1.0");
         QNetworkReply *Reply = manager->get(request);
         connect(manager, SIGNAL(finished(QNetworkReply*)),
                  this, SLOT(replyFinished(QNetworkReply*)));
    
    
    
    }
    
    Widget::~Widget()
    {
    
    }
    void Widget::replyFinished(QNetworkReply *Reply)
    {
    
    }
    void Widget::changeEvent(QEvent *e)
    {
        QWidget::changeEvent(e);
        switch (e->type()) {
        case QEvent::LanguageChange:
    
            break;
        default:
            break;
        }
    }
    i am properly able to access the network and also getting network reply in the slot "replyFinished" ,but i dont know how to
    store this network reply in data object..??

    when i was working on objective-c i used to do this by help of "NSData" which is used to store the data from network request..

    anyone have idea about how to do this in Qt for symbian???

    at first level i want to store the network reply in a string having UTF8 format..??
    Last edited by mind_freak; 2010-04-07 at 07:46.
    Regards
    Viral Parmar

  2. #2
    Regular Contributor
    Join Date
    Oct 2008
    Location
    Oslo, Norway
    Posts
    329

    Re: Storing data from Network reply

    Hi,

    If you check the documentation for the signal you're using (QNetworkReply::finished()), you'll notice the following:

    Unless close() has been called, the reply will be still be opened for reading, so the data can be retrieved by calls to read() or readAll(). In particular, if no calls to read() were made as a result of readyRead(), a call to readAll() will retrieve the full contents in a QByteArray.

  3. #3
    Registered User
    Join Date
    Jan 2009
    Location
    ભારત->ગુજરાત->ભાવનગર
    Posts
    279

    Question Re: Storing data from Network reply

    hi treinio

    this much of i have done ....i mean i have stored the reply data to QByteArray,but i want to clear one thing that is....i want the whole the data in HTML format....what i am getting should be in HTML format??

    i have tried to print this data in Qtextedit but their was the website data printed instead of HTML data....

    do you have any idea about how to perform this operation ??
    Regards
    Viral Parmar

  4. #4
    Nokia Developer Champion
    Join Date
    Feb 2008
    Location
    Ahmedabad, Gujarat, India
    Posts
    3,852

    Re: Storing data from Network reply

    hello viral

    here one thing you need to keep in mind that if your server replies back with a html data, then obvioulsly you will get data in html format.

    The reason you are getting the data in text format might be your server is replying to your client in that format.

  5. #5
    Registered User
    Join Date
    Jan 2009
    Location
    ભારત->ગુજરાત->ભાવનગર
    Posts
    279

    Question Re: Storing data from Network reply

    ya your right.....but what now happening is that i want to display those HTML data.....i have tried it in webview as well as in textedit....but i am unable to see those html data(HTML tags)..

    At the time of debugging i have maked a watch on my QByteArray..their i came to know that i am getting HTML data..but now question comes ..how to display those data ....in HTML format..??

    In short i want to display my QByteArray Data and with HTML format...
    Regards
    Viral Parmar

  6. #6
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Storing data from Network reply

    How are you displaying the data? Many of the text display widgets such as QLabel will, by default, attempt to interpret HTML and display it "properly". You need to change the text format mode (setTextFormat()) to change this behavior.

  7. #7
    Registered User
    Join Date
    Jan 2009
    Location
    ભારત->ગુજરાત->ભાવનગર
    Posts
    279

    Post Re: Storing data from Network reply

    i have used webview as well as textedit,but unable to display the data in HTML format..
    Regards
    Viral Parmar

  8. #8
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Storing data from Network reply

    Not familiar with webview, but with QTextEdit did you set the text with setText(), setHtml(), or setPlainText()?

  9. #9
    Registered User
    Join Date
    Jan 2009
    Location
    ભારત->ગુજરાત->ભાવનગર
    Posts
    279

    Smile Re: Storing data from Network reply

    hey thanks i have tried setPlainText() and its works...

    thanks a lot..
    Regards
    Viral Parmar

Similar Threads

  1. Network Data
    By rameshguna in forum Symbian
    Replies: 0
    Last Post: 2006-07-24, 13:11
  2. Storing User Data
    By _fox in forum Symbian
    Replies: 8
    Last Post: 2005-01-24, 04:40
  3. Can i compress data before sendind throught network
    By ononokung in forum Mobile Java General
    Replies: 1
    Last Post: 2004-08-24, 20:52
  4. Data storing and retrieving with jme
    By el98105 in forum Mobile Java General
    Replies: 0
    Last Post: 2003-04-06, 18:16

Posting Permissions

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