Search code examples
c++qt

QT - Check if QT app is the app in focus


Here is what I want to do :

Check if my Qt app on windows is an app on the front or minimized. If its minimized then draw the users attention by making it blink.

Now how can i detect if the app is minimized or on the background ?


Solution

  • I believe QWidget::isActiveWindow property is what you are looking for. Then, you can call QWidget::activateWindow().

    Looking at the notes:

    if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way.

    This sounds exactly like this blink effect you are trying to achieve.