Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect if a window has been activated?

Tags:

qt

Focus events don't work because they're not sent if you activate your window by clicking on its non-client frame. Also, if you click the internal components of the window THEY will get the focus event, not your window, but the window will still be activated, even if it wasn't active or focused before.

like image 793
JasonGenX Avatar asked May 23 '13 18:05

JasonGenX


People also ask

How do you check if the Windows is activated?

To find out, select the Start button, and then select Settings > System > Activation . You'll be able to confirm that your Windows 11 has been activated and that your Microsoft account is associated with your digital license. Your Microsoft account is not linked to your digital license.

How can I tell if Windows is activated through CMD?

vbs /dli or slmgr. vbs /dlv commands to confirm you're activated. This can generally be done from the Activation screen in the Settings app if your PC isn't activated–you don't have to use the command if you'd rather use the graphical interface.

How do you check Windows 8.1 is activated or not?

In the new pop-up dialog box, enter "slmgr/xpr". 3. Check the new pop-up dialog box. If Windows 8 is successfully activated, software version information and the expiration date will be displayed.

How do you check my Windows is activated or not in Windows 7?

Simply hold down the Windows key on your keyboard and press the BREAK key to open the View Basic Information About Your System page of the System utility in Control Panel. Then scroll to the bottom of this page and view the activation info displayed there.


1 Answers

Qt provides several virtual event handling functions you can use. Since the activation of a window changes its state, you want to handle some change events:

void MyWidget::changeEvent(QEvent * e) {
    if(e->type() == QEvent::ActivationChange && this->isActiveWindow()) {
       // .. this is now the active window      
    }
}

References

  • changeEvent
  • isActiveWindow
like image 73
Zeta Avatar answered Oct 13 '22 21:10

Zeta