How i can detect type of network connection?



  • 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?



  • 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();
    }@


  • 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]


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.