[Qt-interest] How can I get the current cursor's position in dragMoveEvent ?
Benjamin Lau
blwy10v at gmail.com
Mon Aug 10 07:15:38 CEST 2009
On Mon, Aug 10, 2009 at 12:59 PM, Kermit Mei<kermit.mei at gmail.com> wrote:
> On Sun, 2009-08-02 at 23:52 +0800, Benjamin Lau wrote:
>> 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
>
> Thank you, Benjamin. But what you told me I had seen in assistant. I
> can't find the position when I draging something,yet. Maybe I shoul use
> the cursor's position.
>
> Regards.
> Kermit
>
>
So mouseMoveEvent does not work for you as well? As far as I know,
that's the only way to get the cursor's position anyway while the
mouse is moving.
More information about the Qt-interest-old
mailing list