[Qt-interest] HTTP CGI Problems

Bryce Salmi Bryce.Salmi at zoran.com
Wed Sep 16 22:02:41 CEST 2009


Thanks for the reply,
    I am trying to implement QNetworkAccessManager now but am getting stuck. Trying to get a simple piece of the code written to work, I have the following:

QNetworkAccessManager *manager = new QNetworkAccessManager;
manager.get(QNetworkRequest(QUrl("http://192.168.1.20/something.cgi");


I would then follow with the other code such as the connect function.  Is this the correct way to do it?  I tried my best to read the documentation to come up with this. Yet, it still errors complaining that:

Request for member 'get' in 'manager', which is of non-class type 'QNetworkAccessManager*'


Maybe I messed up on the declaration or c++ side of things?


Bryce

-----Original Message-----
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Thiago Macieira
Sent: Wednesday, September 16, 2009 2:37 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] HTTP CGI Problems

Em Quarta-feira 16. Setembro 2009, às 17.37.01, Bryce Salmi escreveu:
> Qt-Interest,
> 
>      I am trying to program HTTP protocol into my Qt program.  When the
> user clicks a button I invoke Qt's HTTP commands to send a GET to an IP
> address and start a CGI script. Before posting here I searched through
> the archives but couldn't find anything that really answered my
> question. An example of my implementation of the HTTP protocol with Qt:
> 
> 
> 
> QHttp http("192.168.1.20");

Don't use QHttp, please. Use QNetworkAccessManager:

> 
> QFile file ("file");
> 
> http.setHost("192.168.1.20");
> 
> http.get("/something.cgi", &file);
> 
> http.close();

QNetworkReply *reply = manager.get("http://192.168.1.20/something.cgi");
connect(reply, SIGNAL(finished()), obj, SLOT(handleFinished()));

When handleFinished() is called, read the data with reply->read() and reply-
>readAll().

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358

Qt Developer Days 2009 | Registration Now Open!
Munich, Germany: Oct 12 - 14     San Francisco, California: Nov 2 - 4
      http://qt.nokia.com/qtdevdays2009




More information about the Qt-interest-old mailing list