QHostInfo

发布时间:2022-06-08 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了QHostInfo脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

QHostInfo 

Header:    #include <QHostInfo>

 

Public Functions

 
  QHostInfo(int id = -1)
  QHostInfo(const QHostInfo &amp;other)
  ~QHostInfo()
QList<QHostAddress> addresses() const
QHostInfo::HostInfoError error() const
QString errorString() const
QString hostName() const
int lookupId() const
void setAddresses(const QList<QHostAddress> &addresses)
void setError(QHostInfo::HostInfoError error)
void setErrorString(const QString &str)
void setHostName(const QString &hostName)
void setLookupId(int id)
void swap(QHostInfo &other)
QHostInfo & operator=(const QHostInfo &other)
QHostInfo & oPErator=(QHostInfo &&other)

static Public Members

void abortHostLookup(int id)
QHostInfo FromName(const QString &name)
QString localDomainName()
QString localHostName()
int lookupHost(const QString &name, QObject *receiver, const char *member)
int lookupHost(const QString &name, const QObject *receiver, PointerToMemberFunction function)
int lookupHost(const QString &name, Functor functor)
int lookupHost(const QString &name, const QObject *context, Functor functor)

Detailed Description

QHostInfo类为主机名查找提供静态函数。

 

QHostInfo使用操作系统提供的查找机制来查找与主机名关联的IP地址,或与IP地址关联的主机名。该类提供了两个静态方便函数:一个异步工作并在找到主机后发出信号,另一个阻止并返回QHostInfo对象。

 

要异步查找主机的IP地址,请调用lookupHost(),它将主机名或IP地址、接收方对象和插槽签名作为参数并返回ID。可以通过使用查找ID调用abortHostLookup()中止查找。

 

例子:

  // To find the IP address of qt-PRoject.org
  QHostInfo::lookupHost("qt-project.org",
                        this, SLOT(printResults(QHostInfo)));

  // To find the host name for 4.2.2.1
  QHostInfo::lookupHost("4.2.2.1",
                        this, SLOT(printResults(QHostInfo)));

 

 
 

 

#################

脚本宝典总结

以上是脚本宝典为你收集整理的QHostInfo全部内容,希望文章能够帮你解决QHostInfo所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。