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

后端 未结 6 1943
逝去的感伤
逝去的感伤 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:49

    Maybe what you want is

    widget->setAttribute(Qt::WA_TransparentForMouseEvents)
    

    ? That's what QRubberBand uses to let it's parent handle the mouse events. As for keyboard events, a QWidget doesn't get any keyboard events unless it has set itself a focusPolicy().

    setFocusPolicy( Qt::NoFocus );
    

    should therefore take care of the keyboard events.

提交回复
热议问题