PDA

View Full Version : translucent background - no mouse event



Talei
8th April 2014, 11:49
Hello,
I have translucent window set like:

setAttribute( Qt::WA_TranslucentBackground, true);
and the problem is that when I do press on transparent part event is not received by MainWindow.

Question how do I receive a mouse press event in that situation?

EDIT: OS Win8 - Qt 5.2

wysota
8th April 2014, 12:34
Did you try setting Qt::WA_NoSystemBackground on the widget instead of Qt::WA_TranslucentBackground?

Talei
8th April 2014, 13:13
Yes I did, and what I got is either white (auto fill false) or back screen.

I must add that widget is QGraphicsView with scene.

PS. Its top level widget with Frameless etc.

wysota
8th April 2014, 13:18
What do you mean by "back screen"?

Talei
8th April 2014, 13:42
Sorry for not detailed description, I display QGraphicsView in full screen mode so screen has black colour. In window mode its black window.

Basically I do display QGraphicsView in full screen mode and show items on scene, scene default color is white and base on QGraphicsView ->viewport()->setAutoFillBackground( true/false); I do get white or black screen not transparent one (in conjunction with WA_NoSystemBackground). Same for QWidget wth no Qt::WA_NoSystemBackground flag.

Solution that I look for is to get transparent / translucent window (QGraphicsView + scene in it) that will receive mouse press events. From search that I done it seams like without Win hook I cant do that. And my app also runs on Mac. That's why I'm looking for Qt specific solution.

PS. Ideal solution would be that I can receive mouse vent (press, move, release) and decide if I want to consume that event or pass it to OS (to underlying applications / windows). But I think that without OS specific code this cant be accomplished - with I hope I'm wrong :). Although just copy is enough.