[Development] Changing qreal to a float

Samuel Rødal samuel.rodal at nokia.com
Tue Feb 21 08:24:52 CET 2012


On 02/20/2012 08:16 PM, ext Thiago Macieira wrote:
> On segunda-feira, 20 de fevereiro de 2012 18.36.50, Marc Mutz wrote:
>> Please look at the numbers that Boudewijn posted in the footnote (in the
>> mail  that you replied to) and realise that you need to keep qreal/QFooF in
>> deprecated peace. I, too, know of too much customer code that'd break
>> otherwise.
>>
>> I actually love Christoph's QRect{D,S} idea. Just template the
>> implementation  (and make QRectX a typedef, don't inherit!!) on the FP type
>> and you can even throw in QRectL into the mix.
>
> Maybe this then:
>
> #if QT_DEPRECATED_SINCE(5,0)
> #  if defined(QT_NO_FPU) || defined(QT_ARCH_ARM) || defined(QT_ARCH_WINDOWSCE)
> typedef float qreal_t;
> #  else
> typedef double qreal_t;
> #  endif
> Q_DECL_DEPRECATED qreal_t qreal;
> #endif
>
>
>
> template<typename T>  class QBasicRect
> {
>      ...
> };
>
> typedef QBasicRect<float>  QRectS;
> typedef QBasicRect<double>  QRectD;
>
> class QRect : public QRect<int>
> {
>      /* constructors */
> };
>
> #if QT_DEPRECATED_SINCE(5, 0)
> Q_DECL_DEPRECATED class QRectF : public QRect<qreal_t>
> {
>      /* constructors */
> };
> #endif
>
>
> I personally don't like the name QBasicRect but QRect is taken already.
> QRectangle would help here, but not for QPoint or QSize. Also, the S and D
> suffixes are weird.

Well, especially the S suffix feels weird, QRectF and QRectD might not 
be that confusing (although not sure how to preserve compatibility 
then). OpenGL uses the same suffixes, as in glUniform2f and glUniform2d etc.

Also, I guess we'll want convenience functions "QRectD QRectF::toRectD() 
const" etc. Can that be done with the typedefs proposed above, or does 
it require having "QRectD QRectD::toRectD() const" as well? :)

--
Samuel



More information about the Development mailing list