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 listen internet connection.
Forum Updated to NodeBB v4.3 + New Features

How to listen internet connection.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 1.4k 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.
  • W Offline
    W Offline
    William.Tran
    wrote on last edited by William.Tran
    #1

    Hi All,

    Do you know are there any way to trigger event network disable or enable?

    I am doing like this:

    networkConfigManager = new QNetworkConfigurationManager();

    //for MAC
    connect(networkConfigManager, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStateChanged(bool)));

    //for windows
    connect(networkConfigManager,SIGNAL(configurationChanged(QNetworkConfiguration)), this, SLOT(networkConfigurationChanged()));

    I don't know why "onlineStateChanged" not working on Windows. I have to use "configurationChanged" as you can see. However, it is not working as expected in case i have some virtual machine network. When i disable/enable internet the events were not fired.

    Could someone help me on this?

    Thank you!

    raven-worxR 1 Reply Last reply
    0
    • W William.Tran

      Hi All,

      Do you know are there any way to trigger event network disable or enable?

      I am doing like this:

      networkConfigManager = new QNetworkConfigurationManager();

      //for MAC
      connect(networkConfigManager, SIGNAL(onlineStateChanged(bool)), this, SLOT(onlineStateChanged(bool)));

      //for windows
      connect(networkConfigManager,SIGNAL(configurationChanged(QNetworkConfiguration)), this, SLOT(networkConfigurationChanged()));

      I don't know why "onlineStateChanged" not working on Windows. I have to use "configurationChanged" as you can see. However, it is not working as expected in case i have some virtual machine network. When i disable/enable internet the events were not fired.

      Could someone help me on this?

      Thank you!

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @William.Tran
      QNetworkAccessManager also has a networkAccessibleChanged() signal
      Maybe this works out better for you.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      0
      • W Offline
        W Offline
        William.Tran
        wrote on last edited by
        #3

        Thank you for your supporting. However, i could not get networkAccessibleChanged signal working as expected. my script is below:

        foreach(QNetworkConfiguration cfg, networkConfigManager->allConfigurations()){
        //if(cfg.name() == "Ethernet 6"){
        QNetworkAccessManager *accessManager = new QNetworkAccessManager();
        accessManager->setConfiguration(cfg);
        qDebug() << cfg.name() << accessManager->networkAccessible();
        connect(accessManager, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)), this, SLOT(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
        //}
        }

        patrikdP 1 Reply Last reply
        0
        • W William.Tran

          Thank you for your supporting. However, i could not get networkAccessibleChanged signal working as expected. my script is below:

          foreach(QNetworkConfiguration cfg, networkConfigManager->allConfigurations()){
          //if(cfg.name() == "Ethernet 6"){
          QNetworkAccessManager *accessManager = new QNetworkAccessManager();
          accessManager->setConfiguration(cfg);
          qDebug() << cfg.name() << accessManager->networkAccessible();
          connect(accessManager, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)), this, SLOT(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility)));
          //}
          }

          patrikdP Offline
          patrikdP Offline
          patrikd
          wrote on last edited by
          #4
          This post is deleted!
          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