Qt:设置IP [英] Qt: Setting the IP

查看:1226
本文介绍了Qt:设置IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将网络设备的IP /网络掩码设置为特定的值,但在Qt中找不到这样做的方法。这很容易找出设备的IP地址(谢谢QNetworkInterface),只是没有改变它,除非我错过了什么?

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?

据我所知更改返回到QNetworkAddressEntry对象的值不会真正更新IP本身。

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

平台是嵌入式linux。

Platform is embedded linux.

我不想诉诸ifconfig的调用,除非我必须!

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

推荐答案

为此,Qt没有执行必要的调用的访问权限。

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

解决方案是构建一个服务守护程序,我们通过DBus联系以执行命令us,然后异步地报告命令的结果。

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.

这篇关于Qt:设置IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆