[Qt-interest] QHostAddress::setHost() not working

Neel Basu neel.basu.z at gmail.com
Sat Mar 14 16:31:36 CET 2009


On Saturday 14 March 2009 19:32:03 Thiago Macieira wrote:
> Neel Basu wrote:
> >Here goes my code
> >-------------------------
> >void ProtocolSegment::setHost(const QString& addr){
> >	qDebug() << "Host " << addr;
> >	host__.setAddress(addr);
> >	qDebug() << "setting Host " << host__.toString();
> >}
> >--------------------------------
> >I am calling setHost("google.com")
> >Output is
> >------------------------------
> >Host  "google.com"
> >setting Host  ""
> >--------------------------------
> >which means setAddress() is not working correctly.
> >I've also tried host__ = aadr e.g. the operator=() overload
> >But same result
> >
> >Any Ideas ??
>
> Yes. What are you exactly trying to do?
>
> The documentation to QHostAddress::setAddress specifically says that it
> supports only IPv6 or IPv4 addresses:
>
>     Sets the IPv4 or IPv6 address specified by the string
>     representation specified by \a address (e.g. "127.0.0.1").
>     Returns true and sets the address if the address was successfully
>     parsed; otherwise returns false.
>
> You passed a hostname. I think you wanted QHostInfo, not QHostAddress.
Oh I thought QHostAddres can hold both IP address and string hostnames

Thanks for Correcting me

Neel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090314/e9692d06/attachment.html 


More information about the Qt-interest-old mailing list