[Qt-interest] Restricting Mouse Movements

Nitin Mahajan nitinm76 at yahoo.com
Tue Sep 8 08:31:13 CEST 2009



--- On Tue, 8/9/09, Ender EREL <erelender at yahoo.com> wrote:

> From: Ender EREL <erelender at yahoo.com>
> Subject: Re: [Qt-interest] Restricting Mouse Movements
> To: qt-interest at trolltech.com
> Date: Tuesday, 8 September, 2009, 11:55 AM
> I don't know if there is an automatic
> way to do this but i don't think 
> so. You can achieve this by following these steps:
> 
> 1 - Override mouseMoveEvent(QMouseEvent* event)[1] for your
> widget.
> 2 - In the overridden mouseMoveEvent, check if the mouse
> position is 
> outside the allowed area. If it is, set the cursor
> position[2] to the 
> nearest position inside your area.
> 
> The widget will normally recieve mouseMoveEvents only if a
> mouse button 
> is down by default. You can recieve mouseMoveEvents when a
> mouse button 
> is not down by calling setMouseTracking(true)[3] on your
> widget.
> 
> [1] - http://doc.trolltech.com/4.5/qwidget.html#mouseMoveEvent
> [2] - http://doc.trolltech.com/4.5/qcursor.html#setPos-2
> [3] - http://doc.trolltech.com/4.5/qwidget.html#mouseTracking-prop
> 
> --
Thanks EREL, I was looking for an Automatic way of restricting such mouse movements, cause I think handling mouseMoveEvents after calling setMouseTracking(true) will be too much of an overload.

regards

-Nitin

> Ender EREL
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
> 


      New Email addresses available on Yahoo!
Get the Email name you&#39;ve always wanted on the new @ymail and @rocketmail. 
Hurry before someone else does!
http://mail.promotions.yahoo.com/newdomains/aa/




More information about the Qt-interest-old mailing list