简体   繁体   中英

Overloading event on QMainWindow blocks all other events

I want to handle the QEvent::WindowDeactivate and for this I overload this function on my QMainWindow derieved class.

class MainWindow : public QMainWindow
....
bool event(QEvent * e); 
....
bool MainWindow::event(QEvent *e)
{
    if(e->type() == QEvent::WindowDeactivate){
        //do smth
    }
}

And after that, this event function starts to intercept all other events in my program. All buttons and widgets in this window stop reacting on mouse clicks and keyboard events are also intercepted. Is there a way to fix this?

I solved the problem: had to add

return QWidget::event(e); 

at the end of event implementation. And after that - everything works fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM