[Development] Changing qreal to a float

andre.poenitz at nokia.com andre.poenitz at nokia.com
Wed Feb 15 12:53:39 CET 2012


> Sletta Gunnar (Nokia-MP/Oslo) wrote:
>  - Using "double" is pure waste for a lot of use cases. QRectF, QPointF, QPainter, QPolygonF, 
> OpenGL, QMouseEvent, QTouchEvent, to name a few. None of these  require the precision 
> offered by double precision floating  point.

Whether having doubles in a QPolygonF or a QRectF is necessary depends on what you are doing with it. If you restrict it to the the current Qt-internal use cases, 'float' is possibly fine, if you use it for general coordinate handling in, say, GIS it is certainly not.

> The only questionable use case is geolocation. We know for a fact that floats have limitations 
> in this area and both Qt3D and QtLocation make use of QVector[2|3|4]D and QMatrix4x4 which 
> will now be a float. However, this is no worse (for device) than it already is, 

It won't be worse in the _embedded_ case (and even there only for the embedded cases that did not use a custom build of Qt with hard-coded 'double' for qreal). Right... 

I seem to remember  we had this kind of discussion in ~2006 already, and back then the resolution was to have "double" at least on the desktop side to cover the GIS cases. Sending someone to the wrong side of a 100m wide river just because the navigation system insisted on using single precision float seemed inacceptable at that time. 

Anyway. It's probably better to go for any kind of uniformity. If that's single precision, it should be made clear  that QPolygonF/QRectF are not meant for applications needing "polygons" in general. Maybe one should consider adding some QPolygonD/QRectD/... later to get the functionality back. Until these exist, it might be worthwhile to keep the (then unconditional) typedef though, to allow easy creation of custom builds of Qt with double precision coordinates.

Andre'



More information about the Development mailing list