[Development] Changing qreal to a float

joao.abecasis at nokia.com joao.abecasis at nokia.com
Fri Feb 17 12:26:50 CET 2012

Ben wrote:
> The concerns are not the signals/slots. Yes, that is one aspect.
> The concern is other code that uses qreal - e.g. people embedding it
> in binary protocols, or using it in printf()'s, etc.
> The vast majority of Qt is probably in the desktop arena, and there
> qreal is a double; and it's probably relied on that way.
> There have also been numerous other concerns raised in this thread
> about why it is not a good idea to simply make qreal a float.
> I agree that the better approach is to simply deprecate qreal and use
> float and double explicitly instead.
> Leave qreal in there for now using its existing functionality; mark it
> deprecated; and in then in 6.0 remove it entirely. (I doubt that could
> be done in a 5.x point release.)
> If anything, the metaobject system should printout warnings about
> qreal being deprecated when used in a signal/slot; the build system
> probably should too.

I think the even better approach, once the necessary changes are done
inside Qt and things settle down, is to drop qreal completely. Don't
pick float or real, don't define it. Or typedef it to some dummy type:

    class qreal_IsNoMore {};
    typedef qreal_IsNoMore qreal;

Force users of qreal to make a conscious decision on what they meant to
use. Less error-prone, less chances for silent breakages.

I think Qt 5.0 is a perfect time to fix the broken concept of qreal,
there's no point in letting something like this linger on until Qt 6.
(Is it even possible to *deprecate* a typedef?).



More information about the Development mailing list