You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Tuesday, May 12th 2015, 1:12pm

QMouseEvent , How to get two precision floating point of mouse position ? for example X=152.46 y=152.33 !

Hi all,
Actually, I have spent many many hours to get the answer but unfortunately I failed.

I know there is a QPointF class which contains the qreal value of mouse position. However, it does return the position with X.00 all the time. I mean it return the nearest integer.

void Widget::mouseMoveEvent(QMouseEvent *event)


qDebug()<<QString::number(event->localPos().x(), 'f', 2 );


All these will return the nearest integer value for example
133.00 for the first one and 133 for the rest.

I need to get 133.17 or 132.89 for example not 133.00 or 133

All idea are appreciated.



Monday, May 18th 2015, 6:41pm

Please have a look…comment-1195852

Laszlo Agocs: "That depends on the platform in question. Many of them provide integer positions only for mouse events."


Monday, May 18th 2015, 6:47pm

I have solved this issue by using QGraphicsItem to represent each pixel in its precision position and using mouseMoveEvent to get the floating precision position.