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. QNetworkInformation on RPI4b causing Segmentation Fault
Qt 6.11 is out! See what's new in the release blog

QNetworkInformation on RPI4b causing Segmentation Fault

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 744 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.
  • W Offline
    W Offline
    WallPulse
    wrote on last edited by
    #1

    Hey all, I am trying to use the QNetworkInformation class to do some basic checks about weather or not the current system is connected to a wifi network is able to reach the internet. It seems like a perfect solution to my use case except that whenever I try to call either networkInformation→supportedFeatures() or networkInformation→reachability(), I get a segmentation fault and my program exits. I am a little confused on why this is happening and if there is any way to fix it. I am currently working on a Raspberry pi4b with the default Raspbian OS on it. When I run program before the Seg fault occurs I get the following warning msgs which seems to be a part of this issue, but it is completely beyond me if there is a way to rectify/fix these msgs.

    Has anyone run into something like this before?

    Warning Messages:

    qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "stateChanged"
    qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "connectivityChanged"
    qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "deviceTypeChanged"
    qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "meteredChanged"
    

    Code Snippet:

    void checkInternetConnectivity(){
    	
        QNetworkInformation *networkInformation = QNetworkInformation::instance();
    
        qDebug() << networkInformation->availableBackends();
    
    
        bool result = networkInformation->loadDefaultBackend();
        qDebug() << "loaded backend: " << result;
    
        qDebug() << "Features:" << networkInformation->supportedFeatures();
       // qDebug() << networkInformation->reachability();
    
    
    }
    
    

    Thanks for any help ahead of time

    C 1 Reply Last reply
    0
    • W WallPulse

      Hey all, I am trying to use the QNetworkInformation class to do some basic checks about weather or not the current system is connected to a wifi network is able to reach the internet. It seems like a perfect solution to my use case except that whenever I try to call either networkInformation→supportedFeatures() or networkInformation→reachability(), I get a segmentation fault and my program exits. I am a little confused on why this is happening and if there is any way to fix it. I am currently working on a Raspberry pi4b with the default Raspbian OS on it. When I run program before the Seg fault occurs I get the following warning msgs which seems to be a part of this issue, but it is completely beyond me if there is a way to rectify/fix these msgs.

      Has anyone run into something like this before?

      Warning Messages:

      qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "stateChanged"
      qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "connectivityChanged"
      qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "deviceTypeChanged"
      qt.dbus.integration: Could not connect "org.freedesktop.NetworkManager" to "meteredChanged"
      

      Code Snippet:

      void checkInternetConnectivity(){
      	
          QNetworkInformation *networkInformation = QNetworkInformation::instance();
      
          qDebug() << networkInformation->availableBackends();
      
      
          bool result = networkInformation->loadDefaultBackend();
          qDebug() << "loaded backend: " << result;
      
          qDebug() << "Features:" << networkInformation->supportedFeatures();
         // qDebug() << networkInformation->reachability();
      
      
      }
      
      

      Thanks for any help ahead of time

      C Offline
      C Offline
      ChrisW67
      wrote on last edited by
      #2

      @WallPulse said in QNetworkInformation on RPI4b causing Segmentation Fault:

      It seems like a perfect solution to my use case except that whenever I try to call either networkInformation→supportedFeatures() or networkInformation→reachability(), I get a segmentation fault and my program exits. I

      Have you checked that networkInformation is not null?

      From the docs:

      QNetworkInformation is a singleton and stays alive from the first successful load() until destruction of the QCoreApplication object.

      Have you called QNetworkInformation::load(), or one of its replacements, before calling QNetworkInformation::instance()?

      W 1 Reply Last reply
      2
      • C ChrisW67

        @WallPulse said in QNetworkInformation on RPI4b causing Segmentation Fault:

        It seems like a perfect solution to my use case except that whenever I try to call either networkInformation→supportedFeatures() or networkInformation→reachability(), I get a segmentation fault and my program exits. I

        Have you checked that networkInformation is not null?

        From the docs:

        QNetworkInformation is a singleton and stays alive from the first successful load() until destruction of the QCoreApplication object.

        Have you called QNetworkInformation::load(), or one of its replacements, before calling QNetworkInformation::instance()?

        W Offline
        W Offline
        WallPulse
        wrote on last edited by
        #3

        @ChrisW67

        Thank you, that fixed it! My bad for missing that.

        Calling QNetworkInformation::loadDefaultBackend() before calling the features function worked

        1 Reply Last reply
        0
        • W WallPulse has marked this topic as solved on

        • Login

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