[Development] Changing qreal to a float

Samuel Rødal samuel.rodal at nokia.com
Mon Feb 20 18:09:31 CET 2012

On 02/20/2012 05:20 PM, ext Boudewijn Rempt wrote:
> On Monday 20 February 2012 Feb, Samuel Rødal wrote:
>> On 02/20/2012 04:58 PM, ext Christoph Feck wrote:
>>> On Monday 20 February 2012 16:02:09 Thiago Macieira wrote:
>>>> I also thought we had agreed that QRectF should be float on all
>>>> platforms and we don't need double-precision geometric classes
>>>> anyway.
>>> I think we agreed on the former, but hopefully not on the latter. Many
>>> geometric classes, such as QLineF, have functions that are used
>>> outside rendering, so having double-precision classes are very useful
>>> to have.
>>> Maybe add explicit QRectS and QRectD classes, and deprecate QRectF
>>> (same for QPointF, QLineF and friends)?
>> This seems quite unfeasible. These classes are mainly used together with
>> QPainter (or scene graph for QML 2),
> Er, I don't think you can put it that way. Those classes were public api in Qt and are used for all kinds of purposes in all kinds of applications. Frankly, this discussion has me dreading the Qt4->Qt5 move... Not just my pet application, Krita, will be affected (1), but customer's applications as well. And those don't ship with a custom-built Qt either.

QLineF / QRectF being split into single / double precision -> QTransform 
/ QMatrix4x4 need the same split, since those operate on QLineF / QRectF.

And thus QVector2D, QVector3D, QVector4D, and QQuaternion also need two 
versions. Should we name those QVector3DS / QVector3DD etc?

I'm just saying it's infeasible and ugly to have two floating point 
versions of each class, I'm not saying we should drop double precision 
support on desktop. Maybe it's better to keep qreal the way it is (Apple 
uses CGFloat which works in a similar way), or to make public facing 
classes use double regardless, and only use single precision floating 
point in the implementation on embedded CPUs. Although, the latter might 
come with a significant performance cost.

These complications make me lean toward just keeping qreal the way it is...


More information about the Development mailing list