> A vector is a sequential collection of items. A polygon is a sequential 
> collection of points. So a polygon can be a vector of points.
> 
> But I don't think that it should inherit, since some of the operations that 
> you can do in a vector don't really apply to a polygon.

1) To build a QPolygon, you need to add (often many) points.
QVector::reserve() is useful for this.

2) resize(0) is useful too, to preserve the allocated memory.

3) Recently, I had to reverse a polygon, std::reverse was useful,... and
this applies to QVector.

4) let me quote the Qt doc, which I think makes sense:

A QPolygon object is a QVector<QPoint>. The easiest way to add points to
a QPolygon is to use QVector's streaming operator, as illustrated below:

        QPolygon polygon;
        polygon << QPoint(10, 20) << QPoint(20, 30);

////////

Indeed, as a user of QPolygon, I do see and handle a QPolygon as a
vector of points...

Philippe

_______________________________________________
Development mailing list
[email protected]
http://lists.qt-project.org/mailman/listinfo/development

Reply via email to