[Qt-interest] Discover IP address and Turn Into QUrl
Robert Escott
robert at binarylogic.co.za
Tue Sep 22 21:05:10 CEST 2009
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
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/c2e55227/attachment.html
More information about the Qt-interest-old
mailing list