[Qt-interest] Events on Transparent Window

BRM bm_witness at yahoo.com
Thu Feb 10 00:18:18 CET 2011


Yes - the described problem sound very similar to what I am doing with my layout 
(see thread "Events and objects...").
The 'installEventFilter' does exactly what you need, without necessarily needing 
a transparent window. In fact, done correctly you just need a wrapper widget 
that intercepts the events you need.

So:
1. Define a new widget class - transparentWindowWidget, base the design on 
QMdiSubWindow
2. in the new widget, when a widget is assigned, install an event filter.
3. do what you want on the events, you can prevent them from going down to the 
children as well.

I'm not sure how this works if you try to add a layout there instead of a widget 
(perhaps a widget needs to wrap the layout?) but it should do what you want, and 
be a lot cleaner as well.
Me - I'm just monitoring for mouse double-click and then pushing the widget in 
and out of being parented by the custom widget to make it pop in/out of the main 
dialog. Still working on it; but it should be 100% effective and has the added 
effect that I (i) don't have to use a custom layout if I don't want to, and (ii) 
I don't have to derive widgets from a custom widget class - they can derive 
directly from QWidget. (My old approach did the work in the QLayout, and 
required all displayed widgets to be derived from a custom widget class. It 
worked; but certainly not as nicely as the new approach will.)

I'm certain you'll find this works very very well and should be pretty seamless 
too.

HTH,

Ben

P.S. To the list - Thanks for the pointer in my thread. Very slick.


>
>From: Jason H <scorp1us at yahoo.com>
>To: Sean Hayes <sean.t.hayes at vanderbilt.edu>; Qt Interest 
><qt-interest at trolltech.com>
>Sent: Wed, February 9, 2011 4:49:20 PM
>Subject: Re: [Qt-interest] Events on Transparent Window
>
>
>Unfortunately, at 0, it is likely to be optimized out. Better to find a way to 
>intercept the event at the parent window and handle it before it is passed to 
>child windows. 
>
>
>I think you can install an event filter on the parent window by subclassing the 
>class and overriding the default handler. It's been a while since I did anything 
>like that but that's how I'd approach it. 
>
>
>Windows has to deliver the event to the MainWindow, where in it gets translated 
>(reltive positioning) through the parent hierarchy before ending up on the final 
>child widget itself. You should be able to intercept any such event early on.
>
>
>
>
________________________________
From: Sean Hayes <sean.t.hayes at vanderbilt.edu>
>To: Qt Interest <qt-interest at trolltech.com>
>Sent: Wed, February 9, 2011 11:19:44 AM
>Subject: [Qt-interest] Events on Transparent Window
>
>I am trying to create a transparent window that overlays multiple other windows 
>and captures all mouse and touch events. Windows touch messages seem to only be 
>set to a window if the initial contact point is over the window. Therefore, if 
>you start a gesture over one window and add a finger over another window, the 
>QTouchEvent will only contain the first touch point. A setup similar to the one 
>in this Windows programing article may solve this problem. However, I do not 
>know much about windows specific code and would prefer to stick with Qt's API 
>for obvious reasons.
>
>
>Setting full transparency causes Windows to send the event directly to the 
>window underneath, defeating the purpose. Any ideas on how to force the 
>transparent window to receve events? I have tried this with 
>QWidget::setWindowOpacity(0).
>
>
>I am using Qt 4.7.1 on Windows 7.
>
>
>Thanks for you help,
>Sean
>________________________________
Need Mail bonding?
>Go to the Yahoo! Mail Q&A for great tips from Yahoo! Answers users.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110209/0da6a574/attachment.html 


More information about the Qt-interest-old mailing list