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 check an ip address of network interface is accessible to network(not internet)
Forum Update on Monday, May 27th 2025

How to check an ip address of network interface is accessible to network(not internet)

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 4 Posters 1.6k Views
  • 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.
  • JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #1

    I use QNetworkInterface::allInterfaces() to get all entry ip addresses. They will be used in an app. The app will crash if they are gone(network disconnected). Is there a way to check if the ip address is accessible to network(not internet) in advance while disconnection can happen at any time and it is not efficient to refresh all interfaces more frequently?

    1 Reply Last reply
    0
    • C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @JoeCFD said in How to check an ip address of network interface is accessible to network(not internet):

      QNetworkInterface

      QNetworkInformation perhaps?

      JoeCFDJ 1 Reply Last reply
      1
      • jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @JoeCFD said in How to check an ip address of network interface is accessible to network(not internet):

        The app will crash if they are gone(network disconnected).

        Why should it crash? I would say you should fix your code.

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        JoeCFDJ 1 Reply Last reply
        1
        • jsulmJ jsulm

          @JoeCFD said in How to check an ip address of network interface is accessible to network(not internet):

          The app will crash if they are gone(network disconnected).

          Why should it crash? I would say you should fix your code.

          JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by
          #4

          @jsulm third party lib. No chance and time to get into it.

          1 Reply Last reply
          0
          • C ChrisW67

            @JoeCFD said in How to check an ip address of network interface is accessible to network(not internet):

            QNetworkInterface

            QNetworkInformation perhaps?

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #5

            @ChrisW67 Thanks for your help. That is for Qt6. I am still using 5.15

            Christian EhrlicherC 1 Reply Last reply
            0
            • JoeCFDJ JoeCFD

              @ChrisW67 Thanks for your help. That is for Qt6. I am still using 5.15

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @JoeCFD said in How to check an ip address of network interface is accessible to network(not internet):

              That is for Qt6. I am still using 5.15

              Then use https://doc.qt.io/qt-5/qnetworkinterface.html

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              JoeCFDJ 1 Reply Last reply
              0
              • Christian EhrlicherC Christian Ehrlicher

                @JoeCFD said in How to check an ip address of network interface is accessible to network(not internet):

                That is for Qt6. I am still using 5.15

                Then use https://doc.qt.io/qt-5/qnetworkinterface.html

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #7

                @Christian-Ehrlicher It is being used to get all interfaces. A timer can be applied to update these interfaces. However, network disconnection can happen at any time.

                1 Reply Last reply
                0
                • JoeCFDJ Offline
                  JoeCFDJ Offline
                  JoeCFD
                  wrote on last edited by
                  #8

                  saved interface names for these ip adresses and check QNetworkInterface::interfaceFromName(const QString &name).isValid() before any ip address is sent out. the crash seems gone. But no 100% guarantee.

                  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