I am working on a project where I want to confirm the existence of a host on a local network. In the QtNetwork package in Qt, the QHostInfo::lookupHost
method is a convenient way of searching for a host without needing to implement any kind of pinging or being dependent on a ping system call. Its asynchronous call makes it convenient to create a dialog waiting for the call to return with a slot in either the dialog or the main program to handle the return.
From Qt's Documentation for 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.
The documentation from PySide for QHostInfo
details usage of lookupHost
but I think it might be automatically generated from the Qt documentation as by default, the method lookupHost
is declared as a private method in the typesystem definition for QtNetwork.
Is there a particular reason that this method is declared private in the PySide implementation? Does it have to do with the asynchronous nature of the call and Python's GIL?
After not receiving an answer from the PySide boards, I changed the line in my PySide typesystem definition file for QtNetwork so that it reads:
<modify-function signature="lookupHost(QString,QObject*,const char*)" access="public"/>
re-compiled PySide and have no issues