[Interest] Wrong mouse move events.

Igor Mironchik igor.mironchik at gmail.com
Wed Apr 22 13:08:00 CEST 2015


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.



More information about the Interest mailing list