[Qt-interest] How to solve grabmouse issue

Ramesh ramesh.bs at robosoftin.com
Thu Jul 29 06:43:01 CEST 2010


Thanks Oliver,
Thanks for your replies to both email's.

As u suggest, I will try to resolve the issue without mousegrab..
It looks kinda horrible  :)...

-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of
Oliver.Knoll at comit.ch
Sent: Wednesday, July 28, 2010 8:25 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] How to solve grabmouse issue

Ramesh wrote on Wednesday, July 28, 2010 3:52 PM:

> ...
> While googling, I found this
>
http://stackoverflow.com/questions/2158810/passing-forwarding-events-to-a-su
b-object-in-qt
>
> I don't know how to implement this

Well then, time to get educated:
http://doc.trolltech.com/4.6/eventsandfilters.html

Basically the answer on Stack Overflow suggests that your first widget gets
the mouse events (button clicks, mouse movement events, ...) and creates new
http://doc.trolltech.com/4.6/qmouseevent.html and send them to other
widgets, as described in above links. However your first widget must map the
mouse coordinates to the ones of the other widget (that is [0, 0] should be
top-left of the other widget AFAIR), such that e.g.
http://doc.trolltech.com/4.6/qmouseevent.html#pos returns the proper
*relative* coordinate (relative to the second widget off course). Also your
first widget needs to know *when* to actually create and forward these mouse
events, that is when the mouse hovers over that other widget. Basically your
first widget - the one which grabbed the mouse - needs to know the exact
whereabout of the other widget (it needs to know the "scene graph" or the
layout of the widgets, where they are placed) - basically what the event
queue of Qt usually does for you(r widgets).

If this all sounds scary to you (and yes, there is some complexity behind
it, especially the mapping of the coordinates) then you are probably better
of by *not* grabbing the mouse in the first place - and let Qt do the proper
mouse event creation ;)

Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest


-----------------------------------------------
Robosoft Technologies - Come home to Technology

Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.



More information about the Qt-interest-old mailing list