不知道这个行不? Qt4.7的
bool QNetworkConfigurationManager::isOnline () const
Returns true if the system is considered to be connected to another device via an active network interface; otherwise returns false.
This is equivalent to the following code snippet:
QNetworkConfigurationManager mgr;
QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active)
if (activeConfigs.count() > 0)
Q_ASSERT(mgr.isOnline())
else
Q_ASSERT(!mgr.isOnline())