我正在做一个项目,我想确认本地网络上是否存在主机。在 Qt 的 QtNetwork 包中,QHostInfo::lookupHost
方法是一种搜索主机的便捷方式,无需实现任何类型的 ping 或依赖于 ping 系统调用。它的异步调用使得创建一个等待调用返回的对话框变得很方便,在对话框或主程序中有一个插槽来处理返回。
来自 Qt 的 QHostInfo 文档:
To look up a host's IP addresses asynchronously, call lookupHost(), which takes the host name or IP address, a receiver object, and a slot signature as arguments and returns an ID. You can abort the lookup by calling abortHostLookup() with the lookup ID...
The slot is invoked when the results are ready. The results are stored in a QHostInfo object. Call addresses() to get the list of IP addresses for the host, and hostName() to get the host name that was looked up.
来自 PySide 的文档 QHostInfo
lookupHost
的详细用法,但我认为它可能是默认情况下从 Qt 文档自动生成的,方法 lookupHost
在 typesystem definition for QtNetwork 中声明为私有(private)方法.
在 PySide 实现中将此方法声明为私有(private)是否有特殊原因?它与调用的异步性质和 Python 的 GIL 有关系吗?
最佳答案
在没有收到来自 PySide 板的答复后,我更改了 QtNetwork 的 PySide 类型系统定义文件中的行,使其显示为:
<modify-function signature="lookupHost(QString,QObject*,const char*)" access="public"/>
重新编译 PySide 没有问题
关于python - 在 PySide 中使用 QtHostinfo.lookupHost,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12533698/