1

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.

Mat
  • 202,337
  • 40
  • 393
  • 406
JP_
  • 1,636
  • 15
  • 26

1 Answers1

4
void accounts::event(QEvent *e)
{
  if (e->type() == QEvent::WindowStateChange) {
    if (isMinimized()) {
      hide();
      e->ignore();
    } else {
      e->accept();
    }
  }
  QMdiSubWindow::event(e);
}
perreal
  • 94,503
  • 21
  • 155
  • 181