Pieter
Pieter

Reputation: 32805

QMainWindow that ignore clicks, passes them on to background windows

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.

Upvotes: 7

Views: 2438

Answers (2)

Bill
Bill

Reputation: 11832

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.

Upvotes: 7

Pieter
Pieter

Reputation: 32805

I did a little more research into "mouse event transparency" (didn't know the exact terminology) and I found this.

I don't think there is a general and easy approach to your problem. You will probably have to dig into the native API. Once events reach an application they are not forwarded to other applications on their own.

What do you guys think? Am I doomed to work with the native APIs of each OS?

Upvotes: 0

Related Questions