Important: Please read the Qt Code of Conduct -

How to find the network availability in Qt?

  • Hi,

    What is the api?


  • any api?

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

  • Qt Champions 2017

    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) {
    if (mgr.isOnline()){
    qDebug() << "connected" <<endl;
    qDebug() << "Inside not connected"<<endl;
    if (!mgr.isOnline()){
    qDebug() << "not connected" <<endl;

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

  • Qt Champions 2017

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

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

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


  • Lifetime Qt Champion


    IIRC, the bearer plugin

Log in to reply