[Qt-interest] HTTP CGI Problems

Mohammed Sameer msameer at foolab.org
Thu Sep 17 10:23:26 CEST 2009


manager is a pointer, use manager->get() not manager.get()

QNetworkAccessManager *manager = new QNetworkAccessManager;
QNetworkReply *reply = manager->get(QNetworkRequest(QUrl("http://192.168.1.20/something.cgi");
QObject::connect(reply, SIGNAL(finished()), blah, SLOT(blahblah));

Cheers,

On Wed, Sep 16, 2009 at 01:02:41PM -0700, Bryce Salmi wrote:
> 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
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 

-- 
GPG-Key: 0xA3FD0DF7 - 9F73 032E EAC9 F7AD 951F  280E CB66 8E29 A3FD 0DF7
Debian User and Developer.
Homepage: www.foolab.org



More information about the Qt-interest-old mailing list