Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Android/Qt: QNetworkInterface change status signal?



  • Hey guys, I can't see any signal/slot system for QNetworkInterface, is there any way to check if the currently pointed interface changes state besides polling it every once in a while? Does it have any way of attaching a signal handler to this class?

    As in IsUp -> something to tell it's down? There is no enum for IsDown, nor can I see the signal in the manual, but maybe there is a way besides constantly polling its state?


  • Lifetime Qt Champion

    @linuxkid

    Hey guys, I can't see any signal/slot system for QNetworkInterface, is there any way to check if the currently pointed interface changes state besides polling it every once in a while?

    Yes, polling is the way to go here. I'd just use a timer with 5 seconds timeout, that should fully suffice. You may even use longer timeouts.

    As in IsUp -> something to tell it's down? There is no enum for IsDown

    If IsUp is not set, then the network is down ;)

    Regards



  • Got it, in the meantime I ended up using a QThread derived class to poll every 50msec.. There is one issue with IsUp, sometimes the interface is up but is still not bound to any IP address.. Is the IsRunnig flag any more complete in this regard? The class should emit a signal whenever its associated and has received an IP (assuming the network profile doesn't has a static one)


  • Lifetime Qt Champion

    @linuxkid said in Android/Qt: QNetworkInterface change status signal?:

    QThread derived class to poll every 50msec

    Why do you need 50ms? 50ms and a thread sounds like overkill.


Log in to reply