[Development] Lack of base classes/interfaces? Q*, Q*F

Ch'Gans chgans at gna.org
Mon Apr 17 04:47:08 CEST 2017


On 17 April 2017 at 13:25, Jason H <jhihn at gmx.com> wrote:
> I am wondering why all the Q* and Q*F classes (where $1 in [Rect, Point, etc]) don't use an interface?
>  I recently moved some code from ints to floats, and I had to change far more code than I should have > had to.
>
> My proposal is to change QRect to QRectI, and make QRect an interface.

This is only the tip of the iceberg, there's the storage type and then
the dimension, Qt has specialised class for int and double in 2 and/or
3 dimensions, and then there's the family of 2+ dimensions with float
(QVector2/3/4D, QMatrixNxM, QQuaternion, ...). I saw a patch not so
long ago about bringing in qfloat16, ...
And I won't mention coordinate systems, ...

Coming with a set of interfaces that plays well together is not an
easy task and things get complicated very quickly. Have a quick read
at boost.geometry "design rational"[1], it looks very sexy at first,
but once you start using it, you realised how cumbersome it can get.

IMHO, there are different use-cases, just to list a few of them:
- 1. GUI/painting tasks (int in 2D 'top-left' CS)
- 2. 3D rendering tasks (float in 2 or 3D)
- 3. Quick and inexact geometry (double in 2 or 3D)
- 4. Exact and robust geometry (other in nD)
- 5. [insert your own here]

I don't believe that you can cover them them all with just one set of
interfaces, different needs require different solutions.

I guess there is lot of history behind Qt current API, it all started
with managing pixels on a screen, didn't it?

I personally would love to see a non-gui module that sits b/w 4 and 5
with "native" support for non-linear curves in 2/3D space...

Chris

[1] http://www.boost.org/doc/libs/1_61_0/libs/geometry/doc/html/geometry/design.html

>
> In the past, I think I remember some pain points between QList and QVector, (or was it QMap, QHash?) which should be QIterable (QIndexable)? Similarly all the string types.
>
> I'm not fan of MS's Ieverything, but I think base classes/interfaces are under used in Qt. Why aren't there more of them?
> _______________________________________________
> Development mailing list
> Development at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/development



More information about the Development mailing list