Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, May 2008
Click-Through-Widget?


Message 1 in thread

Is there a way to make a widget "click-through"?
Meaning mouseclicks should be handled by the underlying widgets (as if
the widget were hidden).
I thought this must be simple, but can't come up with a solution.

Cheers,
Peter

--
 [ signature omitted ] 

Message 2 in thread

You should be able to reimplement the mouse event handler methods and just
call QEvent::ignore() on all of the events that come in. This should cause
the event loop code to pass it up the widget stack.

Tom

On Mon, May 5, 2008 at 10:24 AM, Peter Prade <prade@xxxxxxxxxxx> wrote:

> Is there a way to make a widget "click-through"?
> Meaning mouseclicks should be handled by the underlying widgets (as if
> the widget were hidden).
> I thought this must be simple, but can't come up with a solution.
>
> Cheers,
> Peter
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>

Message 3 in thread

I've tried this, it doesn't work.

From the QEvent::ignore docs:
"Clearing the accept parameter indicates that the event receiver does not want the event. Unwanted events might be propgated to the parent widget."

The problem is, i would want the underlying siblings to process the event, not the parent.
Any non-rectangular widget should have the same problem - that it ends up eating all mouse events of the rectangular bounding box.
Does anyone have a solution for this?

Cheers,
Peter

> -----Ursprüngliche Nachricht-----
> Von: Tom Panning [mailto:lurchvt@xxxxxxxxx] 
> Gesendet: Montag, 5. Mai 2008 16:47
> An: TrolltechInterest
> Betreff: Re: Click-Through-Widget?
> 
> You should be able to reimplement the mouse event handler 
> methods and just call QEvent::ignore() on all of the events 
> that come in. This should cause the event loop code to pass 
> it up the widget stack.
> 
> Tom
> 
> 
> On Mon, May 5, 2008 at 10:24 AM, Peter Prade 
> <prade@xxxxxxxxxxx> wrote:
> 
> 
> 	Is there a way to make a widget "click-through"?
> 	Meaning mouseclicks should be handled by the underlying 
> widgets (as if
> 	the widget were hidden).
> 	I thought this must be simple, but can't come up with a 
> solution.
> 	
> 	Cheers,
> 	Peter
> 	
> 	--
> 	To unsubscribe - send a mail to 
> qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the 
> subject or the body.
> 	List archive and information: 
> http://lists.trolltech.com/qt-interest/
> 	
> 	
> 
> 
> 

--
 [ signature omitted ] 

Message 4 in thread

Answering myself, for the archive:

I've had a closer look at the QRubberband widget (which is
click-through), and saw this line in its c'tor:

	    setAttribute(Qt::WA_TransparentForMouseEvents); 

This window attribute is obviously undocumented, but it seems to do what
i want. 
I've set it for my widget - and voila - my widget is now click-through.

Handle with care, there are some unsolved issues with this attribute:
http://trolltech.com/developer/task-tracker/index_html?searchstr=Transpa
rentForMouseEvents+&method=advsearch&bugs=on&sugs=on

Cheers,
Peter

--
 [ signature omitted ]