Qt - top level widget with keyboard and mouse event transparency?

后端 未结 6 1946
逝去的感伤
逝去的感伤 2020-12-05 02:27

I want an app\'s main window to ignore mouse and keyboard events, passing them to applications underneath it in the window manager Z-order.

I see

6条回答
  •  天涯浪人
    2020-12-05 02:28

    I think that overriding is supposed to work:

    bool YourMainWindow::event( QEvent *event )
    {
       event ->accept();
       return true;
    }
    

    that's some of what the QWidget class documentation says about event() member function:

    This function returns true if the event was recognized, otherwise it returns false. If the recognized event was accepted (see QEvent::accepted), any further processing such as event propagation to the parent widget stops.

提交回复
热议问题