[Interest] Wrong mouse move events.
Igor Mironchik
igor.mironchik at gmail.com
Wed Apr 22 11:34:04 CEST 2015
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