python - 在 PySide 中使用 QtHostinfo.lookupHost

标签 python qt pyside

我正在做一个项目,我想确认本地网络上是否存在主机。在 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 文档自动生成的,方法 lookupHosttypesystem 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/

相关文章:

python - 根据 MA​​C 地址和用户名生成确定性 UUID

c++ - QT COMPILER_MACROS 未在项目开始时定义

python - 如何使用 PySide 导入主窗口(.ui 文件)

resize - 如何调整 QTreeView 和 QStandardItemModel 中的行大小?

python - 从函数式 API 模型上的 Keras CNN Predict() 获取概率

python - Flask 中的 Websocket

c++ - 如何让图形保持在主窗口的中央

qt - 部署 Qt 共享库时替换 RPATH

python - PyQt 获取ListWidget中的特定值

python - 具有多个列的时间序列,每个列都有重复的条目。如何在 Pandas 中处理