How i can detect type of network connection?
-
wrote on 11 Jun 2014, 13:39 last edited by
Hello All!
How i can detect type of internet connection: 3g/wifi/gps/etc ?
i try use:
@QNetworkConfiguration man;
qDebug() << man.bearerTypeName();
qDebug() << man.bearerType();
qDebug() << man.bearerTypeFamily();@
and have output: "" "0" "0";
0 = UnknownConnection
Maybe have some other way? -
wrote on 12 Jun 2014, 07:33 last edited by
What platform are you on? What does man.isValid() say?
In any case, you need to get the configuration from QNetworkConfigurationManager for it to be valid, and then check the details.@ QNetworkConfigurationManager manager;
QList<QNetworkConfiguration> list = manager.allConfigurations();for(int i = 0; i < list.length(); ++i) { qDebug() << list[i].isValid(); qDebug() << list[i].bearerTypeName(); qDebug() << list[i].bearerType(); qDebug() << list[i].bearerTypeFamily(); }@
-
wrote on 12 Jun 2014, 12:46 last edited by
Not sure abt this but have something to find IP addresses(on Windows platform)
@
QNetworkInterface *inter = new QNetworkInterface();
QList<QHostAddress> list;
list=inter->allAddresses();
QString str;for (int i = 0; i < list.size(); ++i) { str = list.at(i).toString(); }
return str;
@[edit: added missing coding tags @ SGaist]
1/3