[Qt-interest] IP address change

Bob Hood bhood2 at comcast.net
Fri Apr 8 19:31:55 CEST 2011


On 4/8/2011 10:54 AM, frares at gmail.com wrote:
> Hi,
>
> I am trying to change an ethernet interface IP address using only Qt, but I
> could not find how.
>
> I have managed to find all interfaces and to select the main one among the
> list from QNetworkInterface::allInterfaces() , and read its IP and netmask ,
> but I could not find how to change those.
>
> Is it possible or do I have to use the OS API ?


Would just using the command line be out of the question?  For example, under
Windows, you need only call netsh.exe to reconfigure a selected interface. 
For example, to change the IP address, netmask, and default gateway, something
like:

    netsh interface ip set address name="<interface_name>" static <ip_address> <netmask> <default_gateway>

Then, just spawn a shell that executes this command with the appropriate
values.  No Qt or OS APIs to locate.

Similar interface management functions might be available on other platforms
as well.




More information about the Qt-interest-old mailing list