Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to find the network availability in Qt?
Forum Updated to NodeBB v4.3 + New Features

How to find the network availability in Qt?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 4 Posters 1.9k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    av2306
    wrote on last edited by
    #1

    Hi,

    What is the api?

    Thanks.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      av2306
      wrote on last edited by
      #2

      any api?

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ankursaxena
        wrote on last edited by
        #3

        I don't think that there is any api for network availability in Qt. But i am not 100% sure.

        Yes. You can find api for any particular platform. Such as there is an api available in windows for network availability.

        1 Reply Last reply
        0
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          I have tried this on windows and it works. Not tried on Linux. Will try.
          @QNetworkConfigurationManager mgr;
          QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active);
          if (activeConfigs.count() > 0) {
          Q_ASSERT(mgr.isOnline());
          if (mgr.isOnline()){
          qDebug() << "connected" <<endl;
          }else{
          qDebug() << "Inside not connected"<<endl;
          }
          }
          if (!mgr.isOnline()){
          Q_ASSERT(!mgr.isOnline());
          qDebug() << "not connected" <<endl;
          }@

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          0
          • A Offline
            A Offline
            av2306
            wrote on last edited by
            #5

            Thanks for your reply.

            I will try with qt build soon.

            I tried with QNetworkConfigurationManager *mngr = new QNetworkConfigurationManager(this);

            bool b = mngr->isOnline();

            It's always return false with build of Qt installer.(in production on user machine)

            When I build binary from qt creator, it's returning correct network status. May I know the reason for this?

            Is there extra library required on user machine?

            1 Reply Last reply
            0
            • dheerendraD Offline
              dheerendraD Offline
              dheerendra
              Qt Champions 2022
              wrote on last edited by
              #6

              @
              QNetworkConfigurationManager mgr;
              QList<QNetworkConfiguration> activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active);@

              Did you query like the above ? It just requires network module. Nothing more.

              Dheerendra
              @Community Service
              Certified Qt Specialist
              http://www.pthinks.com

              1 Reply Last reply
              0
              • A Offline
                A Offline
                av2306
                wrote on last edited by
                #7

                Hi Dheerendra,

                I tried with your code too with build. No luck.

                It's always returning false even though network available.

                If I build binary on my machine, it's returning correct network status.

                Is there any other library dependency while compiling?

                Thanks.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Hi,

                  IIRC, the bearer plugin

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0

                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Users
                  • Groups
                  • Search
                  • Get Qt Extensions
                  • Unsolved