Please nominate your Qt Champions for 2021! https://forum.qt.io/topic/132134/looking-for-the-2021-qt-champions
Appropriate API for detecting network status change
Taytoo last edited by
Trying to figure out how to get notified of Internet availability after disconnection. According to the documentation there are multiple potential APIs:
onlineStateChanged, basically just checks all network interfaces if they are Up or not and if any of them is working, then it returns true. The problem is that if wifi/lan is connected but ISP/internet is down OR wifi/lan is disconnected but a virtual interface (typically created by VMs) is active. In these cases it still returns true/online.
I'm not 100% sure about 1 & 2. Can anyone briefly explain the differences between these APIs and use cases? Is there an API that notifies when Internet becomes (un)available?
Is there an API that notifies when Internet becomes (un)available?
There is no such API in Qt. If you want to check, periodically ping some well-known host (your server or google.com etc.). There are some native APIs for detecting Internet access, for example on Android. But there is no common API for all systems (at least in Qt).