Qt 如何检查网络是否畅通
有没有简单而实用的方法
[最优解释]
#include <QtCore/QCoreApplication>
#include <QtNetwork/QHostInfo>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QHostInfo info = QHostInfo::fromName(QString("www.7uiuyhjniu78cdefe.com"));
if(info.addresses().isEmpty())
cout << "error" << endl;
else
cout << "ok" << endl;
return 0;
}