[Qt-interest] why does QGrahicsView framework uses floats for coordiantes ?

Thiago Macieira thiago at kde.org
Wed Jun 30 14:56:47 CEST 2010


On Wednesday 30 June 2010 14:17:42 Pritam Ghanghas wrote:
> Hi
> 
> why does QGrahicsView framework uses floats for coordinates ?

It uses qreal, not float.

qreal is double on most desktop systems, and float on embedded systems. The 
difference in choice is the ability of the embedded processor to work on 
double-precision floating point values in a timely fashion.

> is it just to have larger maximum value possible or some other reason?

As opposed to fixed-point? It's because we need floating point: Graphics View is 
not pixel based. The rotations and other transformations applied are all 
floating-point math.

The fact that your API uses floating point makes you remember that you're not 
dealing with pixels.

> and
> is there a performance penalty because of that if my hardware doesn't
> have a FPU?

Yes, there will be a noticeable performance penalty. But that's why it uses 
single precision instead of double precision, so that the impact is smaller.

> I found my Qwidgets to be signifacntly faster than QGraphicsItems. which
> is unexpected considering docs say that QGaphicsitems are lighter than
> Qwidgets.

It depends on what you're doing with each. And, of course, the lack of an FPU 
will be a major impact.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100630/888b8695/attachment.bin 


More information about the Qt-interest-old mailing list