Qt detect when computer goes into sleep?

后端 未结 3 410
半阙折子戏
半阙折子戏 2021-01-17 20:16

How can i detect when a users computer goes into sleep (laptop lid closes, sleep mode due to inactivity, etc)?

I need to do this to disconnect the users TCP connecti

3条回答
  •  情话喂你
    2021-01-17 20:32

    You need to use the QNetworkConfigurationManager class available in Qt 4.7 and above.

    QNetworkConfigurationManager provides access to the network configurations known to the system and enables applications to detect the system capabilities (with regards to network sessions) at runtime.

    In particular look at the void QNetworkConfigurationManager::onlineStateChanged(bool isOnline) signal.

提交回复
热议问题