[SOLVED]glutMouseMotion in QGLWidget
-
hi..
I want to track mouse motion like GLUT Function Callback : glutMotionFunc
so it will return mouse in relative positionhow can I use that glutMotionFunc in QGLWidget
or there is another way to track with mouseMoveEvent ?Thanks...
-
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
MyGLClass.h
@
class MyGLClass : public QGLWidget
{
Q_OBJECT
private:
int old_x;
int old_y;
void mouseMotion(int x, int y);
...
protected:
void mousePressEvent(QMouseEvent *event);
...
}
@MyGLClass.cpp
@
....
void MyGLClass::mouseMoveEvent ( QMouseEvent * event )
{
int motionX = event->x() - old_x;
int motionY = event->y() - old_y;
mouseMotion(motionX, motionY);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 zeroI want to keep track the mouse relative position even if in the edge of the screen
like glutMotionFunc or DirectInput doesThanks, 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..
Thank you..