Can we see the code? QString::number() should work fine in conjunction with QPointF::x and QPointF::y.
Can we see the code? QString::number() should work fine in conjunction with QPointF::x and QPointF::y.
I have used a simple QString("%1").arg(QPointF::x());
Ok. will try your idea.
THank you.
Maverick
P.S
I have used this:
QString(QString::number(mouseEvent->scenePos().x())))
but also show only the int part.
Any ideas?
Last edited by maverick_pol; 16th August 2007 at 15:40.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
I think you write:
QPointF pt = mouseEvent->scenePos();
QString str = QString("%1,%2").arg(pt.x()).arg(pt.y());
Rajesh Kumar Singh
Bangalore, India.
Qt Search
Must Watch:
See how we can connect digital world objects to our day to day life….
Hi,
I have tried this solution in the first place. It shows only INT values.
Maybe the INT value is read from the scene, and it's not the case of converting it to string. How to read scenePOS with high precision?
Beforehand thanks!
Maverick
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Hi,
I will try the QString::setNUM, but I have just used qDebug() to show mouseMoveEvent->scenePos().x(), and it show INT values. It seems that I am reading coordinates as INT values. THe question is: how to read coordinates with higer precision?
Beforehand thanks!
Maverick
P.S.
I have tried using this:
Qt Code:
QString wspX; wspX.setNum(mouseEvent->scenePos().x(),'g',10); qDebug()<<wspX;To copy to clipboard, switch view to plain text mode
shows only the Decimal values(INTs).
Last edited by maverick_pol; 17th August 2007 at 09:26.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
I think your "problem" is that the fraction part of your coordinates are simply "0" thus the decimal point and zeros that follow are simply discarded. Are you sure the coordinates have non integer values?
Hi,
I draw a custom background using some VPF data. I create polygon from pair coordinates. There is a lot of coor. like: 3.234, 1.234...etc When I print coord before drawing the background. Because I draw using( example 3.234) coordinate I would like to read the same coordinates with the same precision.
But now I am a bit confused. I need to have a good precision because after zooming the scene 10 times I should be able to see high precision coordinates(3.234) not only the jump from 3->4->5...etc.
Maverick
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Can we see the exact code reproducing the problem?
I belive that the code is not a problem, rather the understanding of coordinates system.
I am passing from signal to slot the:
scenePos().x() in the qDebug() show the int, so I belive that I am reading only int values, but need to also read the decimal fraction.
How to do it is the problem.
But...when I zoom, let's say 3 times, I get high precision coordinates.(because the distance between 2 point is bigger, and this maybe be the reason).
Last edited by maverick_pol; 17th August 2007 at 13:30.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
You are getting an integer, because the fraction part is zero. Pixels on the screen are so big (the scale can be 1:1 or smaller) compared to the scene coordinates, that you can't "click" on points that have noninteger coordinates.
Ok, that's a good point, but I have an application written in MFC that uses CDC to paint my map and show the .xxx values.
And I am suppose to do the same.
Ok, I have just discoverd one thing. When I start the application I get only the INT part of the coordinate, but when I zoom In I get the high precision float(good). Not all.
When I zoom out(the map the same as when I start the app) I get the same high precision float(good), not the INT,even though the map scale is the same as at the begining. ?!!!!!
I have attached screen(when apps start(INT VAL) and after zooming iN/out). Map has the same scale but coords are shown with a different precision)
Maverick
Last edited by maverick_pol; 17th August 2007 at 14:39.
wysotaQt allows you to use everything you want
--------------------------------------------------------------------------------
#if defined(Q_OS_UNIX) && defined(QT_DEBUG)
abort(); // trap; generates core dump
#else
exit(1); // goodbye cruel world
#endif
Bookmarks