Hi, i saw that topic, Lykurg. First method is for Linux system, whilst second is wrong. I search functions to use for Windows.
I wait for more suggestions about my problem.
Hi, i saw that topic, Lykurg. First method is for Linux system, whilst second is wrong. I search functions to use for Windows.
I wait for more suggestions about my problem.
gives you all addresses on your computer. if you also want bcst and mask use QNetworkAddressEntry with its functions broadcast and netmask.Qt Code:
To copy to clipboard, switch view to plain text mode
Trok (16th March 2009)
That's good, but I have next problem. I don't see my general address whilst I see addresses to my router. I don't know how I can solve this problem. Do you have some ideas?
PS. Functions in class QNetworkAddressEntry are useless, because return 0. I don't know why?
Last edited by Trok; 16th March 2009 at 22:57.
There is no such thing as a "main address". There is just a default route that specifies a device to use (on all operating systems). I think one way to find out which your "primary" device is, is to use use a QTcpSocket and have it "connect" to a possibly non-existing address that is not on the local network, then use QAbstractSocket's localAddress() which returns a QHostAddress, which in turn contains the IP of the local interface. After that you can then find ouch wich interface has the said IP by searching through the list of QNetworkInterfaces.
I think there might be a easier way to find out which is your default network interface, but those approaches possibly require a linux/windows shell and are not platform independent.
Bookmarks