PDA

View Full Version : QMutableVectorIterator and QPointer?



Scorp2us
8th November 2008, 16:38
QVector QPointer <QGraphicsItem> > _graphicsItems;

QMutableVectorIterator<QPointer <QGraphicsItem> > pit(_graphicsItems);
QPointer <QGraphicsItem *> pi;
while (pit.hasNext())
{
pi = pit.next();
if (pi) delete pi;
pit.remove();
}

Won't compile. What am I doing wrong?


For source and errors:
http://pastebin.ca/1248802

caduel
8th November 2008, 20:39
QPointer requires held objects to derive from QObject
(as it monitores the objects by its destroyed signal).

Use smart pointers (e.g. Boost, or Qt 4.5) if you want to watch non-QObjects.