[Qt-interest] How can I get the current cursor's position in dragMoveEvent ?

Benjamin Lau blwy10v at gmail.com
Sun Aug 2 17:52:49 CEST 2009


On Sun, Aug 2, 2009 at 11:46 PM, Benjamin Lau<blwy10v at gmail.com> wrote:
> On Sun, Aug 2, 2009 at 5:26 PM, Kermit Mei<kermit.mei at gmail.com> wrote:
>> Hello, I want to drag something, and I need to get the cursor's position
>> in the dragMoveEvent(event). I can't use event->pos(), because is
>> returns the position where the drag was make. But what I want is the
>> current moved position, how can I get it?
>>
>> Thanks.
>> Kermit Mei
>>
>> _______________________________________________
>> Qt-interest mailing list
>> Qt-interest at trolltech.com
>> http://lists.trolltech.com/mailman/listinfo/qt-interest
>>
>
> dragMoveEvent is only called once when the drag starts. If you want
> the position of the mouse as the mouse is moving, use the
> mouseMoveEvent event handler.
>
> For more information, see here:
> http://doc.qtsoftware.com/4.5/qwidget.html#mouseMoveEvent
>
> Hope this is what you're looking for!
> Benjamin
>

Ok, sorry, I was a bit inaccurate in my explanation of dragMoveEvent.
dragMoveEvent is called when the drag is in progress AND when the
cursor enters/leaves the widget OR a modifier key is pressed while the
widget has focused. See here for more information:
http://doc.qtsoftware.com/4.5/qwidget.html#dragMoveEvent

Sorry for the inaccurate bit.
Benjamin



More information about the Qt-interest-old mailing list