Important: Please read the Qt Code of Conduct -

applicationStateChanged not called when computer goes to sleep

  • Hi

    I am looking for a way of detecting when the computer goes to sleep in my application. I am using Qt 5.3 and the target platform is Linux. I have found applicationStateChanged() emitted by QGuiApplication, but this signal does not seem to be emitted. Am I missing something or is there another way of detecting when computer goes to sleep ?


  • @cristeab Hi! The D-Bus service "org.freedesktop.UPower" offers the signals you need.

  • Qt is a framework for RAPID DEVELOPMENT our app .so it has not most API of native platform .other words for some work you need get privileges adminstrator and root or sudo for accessing this ability to your app.
    in windows for do these work we use win32api.
    in linux you should work with kernel and signals.
    so your object you should add some native platform c++/c code to your Qt projects.that Qt call it Qt Android Extras or Qt X11 Extras and ...............
    if you use Extras your app cannot be crossplatform.

  • Hi

    Thanks for the replies. How about using QAbstractNativeFilterEvent() ? It seems that on Windows this works.


  • @cristeab On Linux, the Desktop Bus (D-Bus) was exactly invented for stuff like this. It replaced everything else and all the distros are using this for years. The next thing that will be replaced will be the X server (Wayland will be its successor) . And now you want to write new code that handles Xcb events? I don't think that's a great idea. Just use D-Bus. It's also supported by Qt ->

  • ok, thanks for the information.

Log in to reply