[Interest] Wrong mouse move events.
Jason H
jhihn at gmx.com
Wed Apr 22 16:24:29 CEST 2015
First, mouse moves are unpredictable.
I have a drawing app that looses the mouse moves. instead of a line like:
________________
I'll get ___.___.___ ____
Depending on how you are doing signals,slots, they might not be direct invocations, and can be queued. Queues can be messed with. (like multiple paints can be collapsed to one)
But I'm not sure what you are intending to do. You are d->pos = e->pos() in the move event, I'd think you want to track the distance from the clicked point?
> Sent: Wednesday, April 22, 2015 at 7:08 AM
> From: "Igor Mironchik" <igor.mironchik at gmail.com>
> To: "interest at qt-project.org" <interest at qt-project.org>
> Subject: Re: [Interest] Wrong mouse move events.
>
> What I understood after research: all is ok with my code, all is ok with
> my mouse...
>
> But I have such problem. And I don't know what to do :(
>
> On Wed, 22 Apr 2015 12:34:04 +0300, Igor Mironchik
> <igor.mironchik at gmail.com> wrote:
>
> > Hi guys,
> >
> > In the following code:
> >
> > //! Pressed?
> > bool pressed;
> > //! Position.
> > QPoint pos;
> > //! Mouse move delta.
> > int delta;
> >
> > void
> > Envelope::mousePressEvent( QMouseEvent * e )
> > {
> > if( e->button() == Qt::LeftButton )
> > {
> > d->pressed = true;
> > d->pos = e->pos();
> > d->delta = 0;
> > }
> >
> > e->accept();
> > }
> >
> > void
> > Envelope::mouseMoveEvent( QMouseEvent * e )
> > {
> > if( d->pressed )
> > {
> > const QPoint delta = d->pos - e->pos();
> >
> > d->delta += delta.manhattanLength();
> >
> > d->pos = e->pos();
> >
> > e->accept();
> >
> > emit moved( delta.x() );
> > }
> > else
> > e->ignore();
> > }
> >
> > emit moved( delta.x() ) emits the next deltas with one direction mouse
> > move:
> >
> > 12
> > -10
> > 11
> > -9
> >
> > etc.
> >
> > I can't understand what I am doing wrong. Is this my mistake, or my
> > mouse is broken, or something else?
> >
> > Thank you.
> >
>
>
> --
> Best Regards,
> Igor Mironchik.
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
More information about the Interest
mailing list