Qt – Ignore mouse and keyboard events in Qt

eventskeyboardmouseqt

In Qt, how can I ignore all mouse and keyboard events and later stop ignoring them? That is: click a button, ignore all events in children; click again, not ignore. Is that clear?
I have the following lines, but maybe I'm doing something wrong:

setAttribute(Qt::WA_TransparentForMouseEvents);

setFocusPolicy(Qt::NoFocus);

Best Answer

Dont use setFocusPolicy(Qt::NoFocus); and it will propagate events to the parent. Use only setAttribute(Qt::WA_TransparentForMouseEvents);