Because you are using QGraphicsPolygonItem. You can probably use something simpler instead.
See examples bundled with Qt.
Yes, because they are the most heavy of your items so they probably occupy about 50% of the memory used by items. A simple esitmate of the memory can be calculated as follows:Also, polygons are mostly only about 10-20% of the total population, the rest are rectangles. Still worthwile to make a new class?
total_per_item = sizeof(QGraphicsItem) + sizeof(data_stored_within_item) where the latter is:
in case of a rect item: sizeof(QRectF) + sizeof(QPen) + sizeof(QBrush) = sizeof(QPointF)+sizeof(QSizeF) + sizeof(QPen)+sizeof(QBrush) = 2*sizeof(double) + 2*sizeof(double) + ...
in case of a polygon item: sizeof(QPolygonF) + sizeof(QPen) + sizeof(QBrush) = sizeof(QVector<QPointF>) + ... = n * sizeof(QPointF) + ... = n*2*double + ... = at least twice as much as for QRectF with n>=4.
So a rect item data occupies probably about 70-80 bytes and a polygon item probably around 100. Add all the additional stuff kept by all the classes to that and multiply by the number of items.
BTW. Also consider using fewer more complex items instead of more simpler ones. Maybe you can "connect" your trapezoids into more complex shapes?
Bookmarks