1

I'd like to set the IP/Netmask of a network device to a specific value but can't find a way to do this in Qt. It's easy enough to find out the IP address of a device (Thank you QNetworkInterface) just not to change it unless I've missed something?

As far as I can tell changing values that are reported back into QNetworkAddressEntry objects won't actually update the IP itself.

Platform is embedded linux.

I'd rather not resort to a call to ifconfig unless I have to!

Rob
  • 335
  • 8
  • 23
  • AFAIK it's not possible. all the related classes are read only (apart from the network address entry, which is only an encapsulation). You'll have to resort to IOCTL's or ifconfig scripts. – Not_a_Golfer Mar 08 '12 at 15:18
  • 2
    That's a system administration task and not covered by Qt. It requires administrator/root permissions on most OSes supported by Qt, which UI applications usually don't have in a normal (and secure) setup. Also, messing with such settings from an application directly instead of using the system's configuration facilities would be considered very bad style in most if not all environments. – Frank Osterfeld Mar 08 '12 at 18:07
  • Fair enough, I didn't think it would be likely. Cheers anyhow! – Rob Mar 09 '12 at 08:33
  • Frank - If you could add that comment as a response I'll accept it rather than leave an open question hanging. – Rob Mar 29 '12 at 17:16

1 Answers1

2

As suspected there is no way to do this, Qt does not have the access permissions to perform the necessary calls.

The solution has been to construct a service daemon that we contact via DBus to execute commands for us, this then reports back asynchronously the result of the command.

Rob
  • 335
  • 8
  • 23