Question

I have a QMdiSubWindow and I need to filter the minimize event so that I can simply hide() the window.

I have tried the following:

void accounts::changeEvent ( QEvent *event )
{
     if(event->QEvent::WindowStateChange) {
          event->ignore(); 
     }
}

This filters ALL window state changes, such as maximize. I need the minimize event exclusively.

event->ignore() doesn't ignore anything. I also tried event->setAccepted(false), which was also unsuccessful at cancelling out events.

Was it helpful?

Solution

void accounts::event(QEvent *e)
{
  if (e->type() == QEvent::WindowStateChange) {
    if (isMinimized()) {
      hide();
      e->ignore();
    } else {
      e->accept();
    }
  }
  QMdiSubWindow::event(e);
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top