Try with this->isActiveWindow() to know whether your current window is active or not.