×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    QNetworkAccessManager

    Hello all,

    I am developing an application using qt for symbian.

    In my application i have to send a query to server and server return a xml file format data ,which i have to parse and display data using Qlistwidget.
    Everything is working fine in emulator.

    This application is run when WI-FI connection is active or through GPRS Connection

    But the problem is:

    1.when i install in to my mobile and run it, first time it will ask for activation of WI-FI connection ,when i activated it it will run but for second
    query it will again asking activation of wi-fi.


    Like this when i need to fetch some data from server using

    manager->post(QNetworkRequest(QUrl(url)),myData); code always (again and again)it will ask wi-fi activation.

    So please help me how do i solve this problem.

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

    Re: QNetworkAccessManager

    I'm guessing you need to become familiar with the Qt Mobility stuff.

  3. #3
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    Re: QNetworkAccessManager

    Hello all,

    I know Qt and i almost finished the project ,but only one problem is that

    it will ask for wifi connection each time when i will request a query to server.

    If you will tell me the solution then i will thankful to you sir.

  4. #4
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: QNetworkAccessManager

    Set default access point to your application. May be this article is useful to you.
    http://wiki.forum.nokia.com/index.ph..._Mobility_APIs

  5. #5
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    Re: QNetworkAccessManager

    hello sir.

    Thank you for your reply.

    But sir i am using QNetworkAccessManager.

    and i don't know how do i use QNetworkConfigurationManager .

    So please tell me how can i solve my problem using QNetworkAccessManager.

    Is any thing is required to add in .pro file while using QNetworkAccessManager.

    Please sir help me.

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

    Re: QNetworkAccessManager

    hello shaktiqt123

    you need to use the bearer management APIs in that, so you need to mention that in the pro file.

    And for setting Access Point you need to use QNetworkConfigurationManager, try using the code suggested by Savaj and that will work for sure.

    Regards,

  7. #7
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    Re: QNetworkAccessManager

    HI girija thanks for your reply.

    Can you please give me a lines of code where do i send a request to server and get data in the form of xml file and can able to parsing it.

    Yes i have done all these things using QNetworkAccessManager and in reply of that
    i get QByteArray data and i am able to parse it .My project is all most finished ,but finally i got problem like "prompts to select Access Point for each request/network".

    my code is like :
    AllmallkeywordList::AllmallkeywordList(QString Keyword)
    {
    url= new QUrl;
    manager_key = new QNetworkAccessManager(this);
    connect(manager_key, SIGNAL(finished(QNetworkReply*)),SLOT(downloadFinished(QNetworkReply*)));
    QByteArray myData("ABC");
    manager_key->post(QNetworkRequest(QUrl("http://www.fgtpl.com/fugenx1/public_html/smartphone/allmall_keywordList.php?keyword="+Keyword)),myData);


    }

    void AllmallkeywordList::downloadFinished(QNetworkReply *reply_key)
    {
    if (reply_key->error() == QNetworkReply::NoError)
    {
    by_k=reply_key->readAll();
    }
    else
    {
    if(reply_key->error() == QNetworkReply::HostNotFoundError)
    {
    QMessageBox::information(this, tr("HTTP"),tr("Connection Fail: %1.").arg("Host Not Found"));
    }
    if(reply_key->error() == QNetworkReply::TimeoutError)
    {
    QMessageBox::information(this, tr("HTTP"),tr("Connection Fail: %1.").arg("Host Not Found"));
    }
    }
    QXmlStreamReader xml;
    xml.addData(by_k);
    while (!xml.atEnd())
    {
    if (xml.isStartElement() && xml.name() == "all_mall")
    {
    QXmlStreamAttributes attrs = xml.attributes();
    MallName = attrs.value("mallName");
    No_Of_Shop = attrs.value("noofshop");
    QString Mall_noofshop = MallName.toString()+"("+No_Of_Shop.toString()+")";
    Stringlist_Mall_no_ofshop << Mall_noofshop;
    if (MallName.isEmpty())
    {
    xml.readNext();
    continue;
    }
    }
    else if(xml.isEndElement() && xml.name() == "all_malls")
    {
    emit parsingAllmallkeyword(Stringlist_Mall_no_ofshop);
    break;
    }
    xml.readNext();
    }
    }


    Big problem is Application prompts to select Access Point for each request/network call .

    So kindly send me an example of Bearer Management APIs from Qt Mobility(like above code) where do i send a request to server i get a data as an xml file and parse it.

    with regards,

    shakti
    Last edited by shaktiqt123; 2010-04-14 at 20:07.

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

    Re: QNetworkAccessManager

    Quote Originally Posted by shaktiqt123 View Post
    HI girija thanks for your reply.
    First of all my name is Gargi


    Quote Originally Posted by shaktiqt123 View Post
    Big problem is Application prompts to select Access Point for each request/network call .

    So kindly send me an example of Bearer Management APIs from Qt Mobility(like above code) where do i send a request to server i get a data as an xml file and parse it.

    Secondly i will again tell you to go through the class QNetworkConfigurationManager Class in the Qt docs, there they have clearly explained about how to set up a default access point, if that doesn't help try using the code given in the article pointed by Savaj.

    Regards,

  9. #9
    Registered User
    Join Date
    Dec 2009
    Posts
    47

    Re: QNetworkAccessManager

    Hello Gargi sorry i spell your name wrongly.

    Ya i use #include "qnetworksession.h" but it shows error "the file 'qnetworksession.h' cannot be opened".

    I am using qt 4.6.0 and i think QtMobility is not inbuild on qt 4.6.0.

    So please tell me how do i configure Qtmobility .
    if i have install qt 4.6.2 then can i find qtmobility there?

    On that link i can not find how to configure.

    So please kindly tell me how do i configure qtmobility.
    and send me some qtdocs where do i read QNetworkConfigurationManager .

    with regards,

    shakti

  10. #10
    Super Contributor
    Join Date
    Oct 2007
    Location
    જુનાગઢ - India
    Posts
    3,034

    Re: QNetworkAccessManager

    Still Qt Mobility APIs are not bundled with Qt so you need to install it seperately after installing Qt 4.6.2

  11. #11
    Nokia Developer Champion
    Join Date
    Mar 2006
    Location
    Helsinki, Finland
    Posts
    8,344

    Re: QNetworkAccessManager

    Nokia Developer Wiki Moderation team

Similar Threads

  1. Replies: 2
    Last Post: 2010-03-23, 08:15

Posting Permissions

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