#include "networkinformation.h"
#include "ui_networkinformation.h" networkinformation::networkinformation(QWidget *parent) :
QWidget(parent),
ui(new Ui::networkinformation)
{
ui->setupUi(this);
getHostInformation ();
connect (ui->detailBtn,SIGNAL(clicked()),this,SLOT(slotDetail()));
} networkinformation::~networkinformation()
{
delete ui;
} void networkinformation::getHostInformation ()
{
QString localHostName = QHostInfo::localHostName ();
ui->lineEditLocalHostName->setText(localHostName); QHostInfo hostInfo = QHostInfo::fromName (localHostName);
QList<QHostAddress> listAddress = hostInfo.addresses ();
if(!listAddress.isEmpty ())
{
ui->lineEditAddress->setText(listAddress.first().toString());
}
} void networkinformation::slotDetail ()
{
QString detail="";
QList<QNetworkInterface> list=QNetworkInterface::allInterfaces ();
for(int i=0;i<list.count();i++)
{
QNetworkInterface interface=list.at(i);
detail=detail+"equipment :"+interface.name()+"\n";
detail=detail+"hardware address :"+interface.hardwareAddress ()+"\n";
QList<QNetworkAddressEntry> entryList=interface.addressEntries ();
for(int j=0;j<entryList.count ();j++)
{
QNetworkAddressEntry entry=entryList.at(j);
detail=detail+"\t"+"IP Address :"+entry.ip ().toString ()+"\n";
detail=detail+"\t"+"subnet mask :"+entry.netmask().toString ()+"\n";
detail=detail+"\t"+"broadcast address :"+entry.broadcast ().toString ()+"\n";
}
}
QMessageBox::information (this,"detail",detail);
}

  

QT 网络编程的更多相关文章

  1. Qt网络编程QTcpServer和QTcpSocket的理解

    前一段时间通过调试Qt源码,大致了解了Qt的事件机制.信号槽机制.毕竟能力和时间有限.有些地方理解的并不是很清楚. 开发环境:Linux((fedora 17),Qt版本(qt-everywhere- ...

  2. QT网络编程

    bool QAbstractSocket::waitForReadyRead(int msecs = 30000) bool QAbstractSocket::waitForDisconnected( ...

  3. GeoServer-REST应用:基于Qt网络编程一键同步发布空间数据和样式至GeoServer

    @ 目录 简介 配置 步骤   1.引入Qt网络模块   2.创建网络管理.网络响应.网络请求   3.创建工作空间   4.创建数据存储并上传数据   5.上传样式文件   6.图层发布   6.图 ...

  4. QT 网络编程三(TCP版)

    QT客户端 //widget.h #ifndef WIDGET_H #define WIDGET_H #include <QWidget> #include <QTcpSocket& ...

  5. QT 网络编程二(UDP版本)

    QT的UdpSocket接收消息使用原则 第一步:new一个UdpSocket 第二步:调用UdpSocket的bind方法,同时指定端口号 第三步:使用connect将接收消息函数和UdpSocke ...

  6. QT网络编程Tcp下C/S架构的即时通信

    先写一个客户端,实现简单的,能加入聊天,以及加入服务器的界面. #ifndef TCPCLIENT_H #define TCPCLIENT_H #include <QDialog> #in ...

  7. QT网络编程UDP下C/S架构广播通信

    QT有封装好的UDP协议的类,QUdpSocket,里面有我们想要的函数接口.感兴趣的话,可以看看. 先搞服务端吧,写一个子类,继承QDialog类,起名为UdpServer类.头文件要引用我们上边说 ...

  8. 5、QT分析之网络编程

    原文地址:http://blog.163.com/net_worm/blog/static/127702419201002842553382/ 首先对Windows下的网络编程总结一下: 如果是服务器 ...

  9. QT分析之网络编程

    原文地址:http://blog.163.com/net_worm/blog/static/127702419201002842553382/ 首先对Windows下的网络编程总结一下: 如果是服务器 ...

随机推荐

  1. IIS7应用程序池集成和经典的区别

    IIS7应用程序池集成和经典的区别 IIS7应用程序池有集成和经典两种模式,根据微软官方的介绍, 集成模式,如果托管应用程序在采用集成模式的应用程序池中运行,服务器将使用 IIS 和 ASP.NET ...

  2. 机器学习常用Python扩展包

    在Ubuntu下安装Python模块通常有3种方法:1)使用apt-get:2)使用pip命令(推荐);3)easy_instal 可安装方法参考:[转]linux和windows下安装python集 ...

  3. 对接第三方支付接口-获取http中的返回参数

    这几天对接第三方支付接口,在回调通知里获取返回参数,有一家返回的json格式,请求参数可以从标准输入流中获取. //1.解析参数 , 读取请求内容 BufferedReader br; String ...

  4. Windows重启网络命令

    netsh winsock reset ipconfig /flushdns

  5. cookie的session_id解释

    HTTP协议(http://www.w3.org/Protocols/)是“一次性单向”协议. 服务端不能主动连接客户端,只能被动等待并答复客户端请求.客户端连接服务端,发出一个HTTP Reques ...

  6. AVAudioPlayer播放本地音频

    AVAudioPlayer苹果官方上说一般用于播放本地音频,不能用于播放网络上的音频. 具体的代码:先导入 #import <AVFoundation/AVFoundation.h> // ...

  7. QDirModel

    #include "dialog.h" #include "ui_dialog.h" #include<QInputDialog> Dialog:: ...

  8. Ubuntu上安装Karma失败对策

    在Ubuntu上安装Karma遇到超时 timeout 错误.Google了一下,国外的码农给了一个快捷的解决方案,实测可行,贴在这里: sudo apt-get install npm nodejs ...

  9. java中使用 redis (转载)

    jedis是一个著名的key-value存储系统,而作为其官方推荐的java版客户端jedis也非常强大和稳定,支持事务.管道及有jedis自身实现的分布式. 在这里对jedis关于事务.管道和分布式 ...

  10. 动画黄金搭档:CADisplayLink&CAShapeLayer

    我们在开发中有时会遇到一些看似非常复杂的动画,不知该如何下手,今天的这篇文章中我会讲到如何利用CADisplayLink和CAShapeLayer来构建一些复杂的动画,希望能在你下次构建动画中,给你一 ...