[Development] QList

Martin Smith Martin.Smith at qt.io
Mon Mar 27 09:22:53 CEST 2017

> A vector is a collection of points and so is a polygon. Both are even ordered.

vector<point> is an ordered collection of points, but a QVector can contain anything; QVector<void*> can even contain unlike things, which is truly a tuple. So the problem here is the name QVector. The basic collection should be called QTuple or QArray, and QVector should mean QTuple<QPoint>.

From: Development <development-bounces+martin.smith=qt.io at qt-project.org> on behalf of Marc Mutz <marc.mutz at kdab.com>
Sent: Monday, March 27, 2017 8:55:53 AM
To: development at qt-project.org
Subject: Re: [Development] QList

On Sunday 26 March 2017 22:53:59 Martin Smith wrote:
> >Yes, using vector for an array type was not Stepanov's best choice of
> >terms (he says so himself), but what you're doing is like arguing that
> >"debt" should be spelled "det". Yes, it should. No, it isn't. :)
> I disagree, but if we have accepted that a vector is a collection, then a
> polygon is a vector. Or it at least has a vector.

No and no. A vector is a collection of points and so is a polygon. Both are
even ordered. But there are good reasons for a polygon to be represented as
something else than a vector. E.g. a BSP. Or a platform-specific data type. On
some platforms, where everything is a path, it might even make some sense to
back QPolygon with QPainterPath. Cf. several paint engine implementations
which first have to convert to QPP.

(the API is lying here, btw: QPainer::drawPolygon(const QPoint *, int)
suggests that you can manage the storage youself to avoid using the heap. But
you do that only to have the paint engine create something expensive as a
QPainterPath first chance it gets).

You just rubberducked me into realizing that QPolygon shouldn't even inherit a
QBasicVector. It should probably contain a QPlatformPolygon instead.


Marc Mutz <marc.mutz at kdab.com> | Senior Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts
Development mailing list
Development at qt-project.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/development/attachments/20170327/0a61afd8/attachment.html>

More information about the Development mailing list