[Qt-interest] Discover IP address and Turn Into QUrl

Bryce Salmi Bryce.Salmi at zoran.com
Tue Sep 22 21:48:44 CEST 2009


Robert,

     Thanks for the email. I missed yours and saw Robins email first.
You got it right on and after a little research on the QString docs I
came up with exactly what you suggested. Thanks!

 

 

 

 

Bryce

 

________________________________

From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Robert Escott
Sent: Tuesday, September 22, 2009 3:05 PM
To: qt-interest at trolltech.com
Subject: [Qt-interest] Discover IP address and Turn Into QUrl

 

I'm not quite sure what you're doing inside the QUrl constructor but
have you tried

 

Request.setUrl(QUrl(QString("http://%1/something.cgi").arg(ip)));

 

This is assuming that ip is already in dotted IP format.

 

Robert

 

----- Original Message ----- 

From: Bryce Salmi <mailto:Bryce.Salmi at zoran.com>  

To: qt-interest at trolltech.com 

Sent: Tuesday, September 22, 2009 6:29 PM

Subject: [Qt-interest] Discover IP address and Turn Into QUrl

 

Qt Interest,

     I have been trying to get my IP address (on embedded Qt with ARM)
rather than set it statically.  So far I have successfully been able to
get the IP and turn it into a char* where I can printf( "%s",ip); and
have it return the IP address as a dotted decimal (192.168.1.20).
However, I am trying to use the IP in an HTTP query to invoke a cgi
script.  This works perfectly when I set the IP address statically. Here
is an example assuming ip is a (char *) with the IP already set:

 

QNetworkAccessManager *manager = new QNetworkManager(this);

QNetworkRequest request;

Request.setUrl(QUrl(("http://%s/something.cgi", ip)));

QNetwork Reply *reply = manager->get(request);

 

Testing with printf's and such showed that this should work, I end up
getting http://192.168.1.20/something.cgi but it does not start the
script.  Am I missing something obvious?

 

 

 

 

Bryce

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090922/0eda8fce/attachment.html 


More information about the Qt-interest-old mailing list