[Interest] Wrong mouse move events.
Igor Mironchik
igor.mironchik at gmail.com
Wed Apr 22 12:00:51 CEST 2015
Want to say one thing more. Mouse cursor moves in one direction without
any moves to right/left only in right direction...
What is it?
Thank you.
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.
More information about the Interest
mailing list