首页 星云 工具 资源 星选 资讯 热门工具
:

PDF转图片 完全免费 小红书视频下载 无水印 抖音视频下载 无水印 数字星空

QT6.5网络主机信息查询

后端 810.63KB 23 需要积分: 1
立即下载

资源介绍:

QT6.5网络主机信息查询
#include "widget.h" #include "ui_widget.h" Widget::Widget(QWidget *parent) : QWidget(parent) , ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } //打印函数 void Widget::printResults(const QHostInfo &info) { QList address_list = info.addresses();; foreach(auto address,address_list) { QString protocol = "协议:" + getProtocolName(address.protocol()); QString ip = "ip地址:" +address.toString(); QString globle ; if(address.isGlobal()) globle = "是否全局地址:是"; else globle = "是否全局地址:否"; ui->plainTextEdit->appendPlainText(protocol); ui->plainTextEdit->appendPlainText(ip); ui->plainTextEdit->appendPlainText(globle); ui->plainTextEdit->appendPlainText("\n"); } } //QHostAddress使用 //返回协议名字 QString Widget::getProtocolName(int protocol) { switch (protocol) { case QAbstractSocket::IPv4Protocol: return QString("IPv4"); case QAbstractSocket::IPv6Protocol: return QString("IPv6"); case QAbstractSocket::AnyIPProtocol: return QString("Either IPv4 or IPv6"); case QAbstractSocket::UnknownNetworkLayerProtocol: return QString("Other than IPv4 and IPv6"); default: break; } return QString(" "); } void Widget::on_btn_local_host_name_ip_clicked() { ui->plainTextEdit->clear(); QString name = QHostInfo::localHostName(); QHostInfo info = QHostInfo::fromName(name); ui->plainTextEdit->appendPlainText("本机主机名:" + name); ui->plainTextEdit->appendPlainText("\n"); printResults(info); } void Widget::on_btn_network_host_name_ip_clicked() { ui->plainTextEdit->clear(); QString str = ui->lineEdit->text(); QHostInfo::lookupHost(str,this, &Widget::printResults); } //QNetworkInterface使用 //返回接口名字 QString Widget::interfaceType(int type) { switch (type) { case QNetworkInterface::Unknown: return QString("Unknown"); case QNetworkInterface::Loopback: return QString("Loopback"); case QNetworkInterface::Virtual: return QString("Virtual"); case QNetworkInterface::Ethernet: return QString("Ethernet"); case QNetworkInterface::Slip: return QString("Slip"); case QNetworkInterface::CanBus: return QString("CanBus"); case QNetworkInterface::Ppp: return QString("Ppp"); case QNetworkInterface::Fddi: return QString("Fddi"); case QNetworkInterface::Wifi: return QString("Wifi"); case QNetworkInterface::Phonet: return QString("Phonet"); case QNetworkInterface::Ieee802154: return QString("Ieee802154"); case QNetworkInterface::SixLoWPAN: return QString("SixLoWPAN"); case QNetworkInterface::Ieee80216: return QString("Ieee80216"); case QNetworkInterface::Ieee1394: return QString("Ieee1394"); default: break; } return QString(" "); } void Widget::on_btn_allAddresses_clicked() { ui->plainTextEdit->clear(); QList list = QNetworkInterface::allAddresses(); QHostInfo info; info.setAddresses(list); printResults(info); } void Widget::on_btn_allInterfaces_clicked() { ui->plainTextEdit->clear(); QList list = QNetworkInterface::allInterfaces(); foreach(auto interface,list) { ui->plainTextEdit->appendPlainText("start----------------------------------------------------------"); QString name = "设备底层名:" + interface.name(); QString readname = "设备可读名:" +interface.humanReadableName(); QString type = "接口类型:" + interfaceType(interface.type()); QString macAddress = "硬件(MAC)地址:" + interface.hardwareAddress(); QString maxValue = "最大传输单位:" + QString::number(interface.maximumTransmissionUnit()); ui->plainTextEdit->appendPlainText(name); ui->plainTextEdit->appendPlainText(readname); ui->plainTextEdit->appendPlainText(type); ui->plainTextEdit->appendPlainText(macAddress); ui->plainTextEdit->appendPlainText(maxValue); QList addrList= interface.addressEntries(); foreach(auto addr,addrList) { QString ipaddr = "ip地址:" + addr.ip().toString(); QString mask = "子网掩码:" + addr.netmask().toString(); QString broad = "广播地址:" + addr.broadcast().toString(); ui->plainTextEdit->appendPlainText(ipaddr); ui->plainTextEdit->appendPlainText(mask); ui->plainTextEdit->appendPlainText(broad); ui->plainTextEdit->appendPlainText("\r\n"); } ui->plainTextEdit->appendPlainText("end----------------------------------------------------------"); ui->plainTextEdit->appendPlainText("\n"); } }

资源文件列表:

networkInfo.zip 大约有8个文件
  1. networkInfo/bin/
  2. networkInfo/bin/networkInfo.exe 3.02MB
  3. networkInfo/main.cpp 175B
  4. networkInfo/networkInfo.pro 631B
  5. networkInfo/networkInfo.pro.user 17.39KB
  6. networkInfo/widget.cpp 5.04KB
  7. networkInfo/widget.h 727B
  8. networkInfo/widget.ui 2.53KB
0评论
提交 加载更多评论
其他资源 伯恩光学检测棱镜C5NG图片-缺墨
先导智能检测-VIP资源,禁止外传
伯恩光学检测棱镜C5NG图片-油墨印
先导智能检测-VIP资源,禁止外传
hc32f460 ddl Rev2.2.0固件库
hc32f460 ddl Rev2.2.0固件库及帮助文档。目前官网找不到,上传备份一下。
基于安卓系统钢琴游戏的设计与实现
内容详尽,可私聊作者免费进行教学
IIC协议,超详细,超简单易懂 .zip
IIC协议,超详细,超简单易懂 .zip
vite-page-entry-main.zip
vite-page-entry-main.zip
vite-page-entry-main.zip
vue配置文件配置文件
vue配置文件配置文件
项目一:利用定时器做秒表 项目二:利用外部中断的电灯开关 项目三:抢答器 项目四:利用74HC595的流水灯
stm32cubex + protues 仿真的相关项目开发