Results 1 to 3 of 3

Thread: QHostInfo IP Detection under Vista

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jun 2006
    Posts
    23
    Thanks
    1
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QHostInfo IP Detection under Vista

    Yes. Solved using protocol() method
    Qt Code:
    1. QHostInfo info = QHostInfo::fromName( QHostInfo::localHostName() );
    2. QList<QHostAddress> listAddr= info.addresses();
    3. for( int i = 0; i < listAddr.size(); i ++ )
    4. {
    5. if( listAddr.at(i).protocol() == QAbstractSocket::IPv4Protocol )
    6. {
    7. ipAddress = listAddr.at(i).toString();
    8. break;
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by marcel; 4th May 2008 at 16:09.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.