Qt

Table of Contents

Overview

Reference

QPlainTextEdit

Terminology

Topics

Parenting System

Signals and slots

How-to

Detect if a window has been activated?

Since event() is a virtual protected method, you must explicitly implement it. It won't work as some dynamic things.

bool YourWidget::event(QEvent *e)
{
  if (e->type() == QEvent::WindowActivate) {
    // window was activated
  }
  return QWidget::event(e);
}
class ActivationHandoverMixin:
    def event(self, e):
        if e.type() == QEvent.WindowActivate:
            t = getattr(self, '_activation_target', None)
            if t is not None:
                t.activateWindow()
        return super().event(e)

class PlayerView(ActivationHandoverMixin, QWidget):
    pass

Links