Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    How i can detect type of network connection?

    Mobile and Embedded
    3
    3
    1599
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      maxim.prishchepa 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?

      Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz).

      1 Reply Last reply Reply Quote 0
      • T
        teroa 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();
        }@
        
        1 Reply Last reply Reply Quote 0
        • S
          Suraj Golliwar 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 Reply Last reply Reply Quote 0
          • First post
            Last post