Results 1 to 2 of 2

Thread: QMutableVectorIterator and QPointer?

  1. #1
    Join Date
    Apr 2008
    Posts
    45
    Thanks
    3
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QMutableVectorIterator and QPointer?

    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

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMutableVectorIterator and QPointer?

    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.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.