[SOLVED]glutMouseMotion in QGLWidget
I want to track mouse motion like GLUT Function Callback : glutMotionFunc
so it will return mouse in relative position
how can I use that glutMotionFunc in QGLWidget
or there is another way to track with mouseMoveEvent ?
You must handle, like you sad, http://doc.qt.nokia.com/latest/qwidget.html#mouseMoveEvent .
Thank you for reply
I Already handle mouseMoveEvent in my QGLWidget let say it MyGLClass
class MyGLClass : public QGLWidget
void mouseMotion(int x, int y);
void mousePressEvent(QMouseEvent *event);
void MyGLClass::mouseMoveEvent ( QMouseEvent * event )
int motionX = event->x() - old_x;
int motionY = event->y() - old_y;
old_x = event->x(); old_y = event->y();
void MyGLClass::mouseMotion(int x, int y)
// this function receive mouse in relative position
// e.g. :
// when you move move your mouse left
// x will be -1 ( or -6 ) depends of your speed when move your mouse
the problem is the function mouseMotion receive zero value when mouse reach the edge of the screen
because the delta of before and after of mouse position is zero
I want to keep track the mouse relative position even if in the edge of the screen
like glutMotionFunc or DirectInput does
Thanks, sorry for my english..
Well I was using neat trick, I don't know if this could be apply to QGLWidget...
When there is move on the mouse pointer, calculate delta, and then return mouse pointer to center of the widget. Simple. But the problem is that you need to hide the mouse pointer...
thanks that trick work for QGLWidget also..