PDA

View Full Version : How to transform the phisical cooridinate of QMouseEvent to logical coordinate?



superwave
3rd July 2011, 03:10
I defined a QGLWidget:

NLDCanvas = new QGLWidget;
NLDCanvas->setMinimumHeight(305);
NLDCanvas->setMinimumWidth(460);

I also defined
QPainter ipainter(this);
ipainter.setWindow(QRect(50,50,100,100);

Moreover,In the QGLWidget, I reimplemented the mouseMoveEvent(QMouseEvent *e) function.
And I need to pick the items under the position of the cursor.

However, since the e->posF() is according to the physical coordinate, the result does not has the same value of the item's logical coordinate.

How can I get the logical coordinate of the mouse position of the QGLWidget?

Thanks a lot

Dong Back Kim
5th August 2011, 03:35
I defined a QGLWidget:

NLDCanvas = new QGLWidget;
NLDCanvas->setMinimumHeight(305);
NLDCanvas->setMinimumWidth(460);

I also defined
QPainter ipainter(this);
ipainter.setWindow(QRect(50,50,100,100);

Moreover,In the QGLWidget, I reimplemented the mouseMoveEvent(QMouseEvent *e) function.
And I need to pick the items under the position of the cursor.

However, since the e->posF() is according to the physical coordinate, the result does not has the same value of the item's logical coordinate.

How can I get the logical coordinate of the mouse position of the QGLWidget?

Thanks a lot

Are you talking about coordinate conversion between OpenGL space coordinate and Qt screen coordinate?

Regards,
Dong Back Kim