Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QMainWindow that ignore clicks, passes them on to background windows

Tags:

qt

I'd like to create a semi-transparent information window that doesn't get in the way of the user's other activities. Any clicks on the window should just pass through as if the window wasn't there.

How would you recommend implementing such behavior? Is there an easy way to do it or do I have to follow a clumsy workaround? I'm thinking of hiding the window, re-executing the click, then making the window visible again. But this would still screw up drag'n'drop gestures.

like image 746
Pieter Avatar asked Apr 06 '12 10:04

Pieter


1 Answers

Take a look at an enum value of Qt::WidgetAttribute: Qt::WA_TransparentForMouseEvents:

When enabled, this attribute disables the delivery of mouse events to the widget and its children. Mouse events are delivered to other widgets as if the widget and its children were not present in the widget hierarchy; mouse clicks and other events effectively "pass through" them. This attribute is disabled by default.

like image 153
Bill Avatar answered Oct 06 '22 22:10

Bill