Results 1 to 3 of 3

Thread: How to delete QwtPlotMarker Objects of QMap<int, QList<QwtPlotMarker *> >

  1. #1
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default How to delete QwtPlotMarker Objects of QMap<int, QList<QwtPlotMarker *> >

    Hello,

    i try to delete the objects of this QMap:

    Qt Code:
    1. QMap<int, QList<QwtPlotMarker *> > mapTempMarker;
    To copy to clipboard, switch view to plain text mode 

    The map contains an integer as curveId of a Curve that is attached to a QwtPlot.
    The inner QList contains all pointers to markers that are added to that curve.

    i tried:

    Qt Code:
    1. QMapIterator<int, QList<QwtPlotMarker *> i(mapTempMarker);
    2. while (i.hasNext())
    3. {
    4. i.next();
    5. qDeleteAll( i.value() );
    6. }
    To copy to clipboard, switch view to plain text mode 

    but got these to errors:
    1. template argument 2 is invalid
    QMapIterator<int, QList<QwtPlotMarker *> i(mapTempMarker);

    2. i was not decelared in this scope
    while (i.hasNext())

    What i'm doing wrong and how to delete this map correctly (i mean the objects behind).

    The QMap itself is part of this:

    Qt Code:
    1. class PlotManager::PrivateData
    2. {
    3. public:
    4. PrivateData(){}
    5. ~PrivateData()
    6. {
    7. // Necessary, because "delete" deletes only the pointers, but not the objects behind
    8. qDebug() << Q_FUNC_INFO << "Delete Objects";
    9. qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesPressure);
    10. qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesTemperature);
    11. qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesTemperature);
    12.  
    13. // Delete QMap<int, QList<QwtPlotMarker *> >
    14. QMapIterator<int, QList<QwtPlotMarker *> i(mapTempMarker);
    15. while (i.hasNext())
    16. {
    17. i.next();
    18. qDeleteAll( i.value() );
    19. }
    20.  
    21. }
    22.  
    23. QVector<QwtPlotCurve *> curvesPressure;
    24. QVector<QwtPlotCurve *> curvesTemperature;
    25. QMap<int, QList<QwtPlotMarker *> > mapTempMarker;
    26. };
    To copy to clipboard, switch view to plain text mode 

    Thx
    Stefan
    Last edited by HappyCoder; 19th July 2015 at 07:38.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    4,014
    Thanks
    233
    Thanked 637 Times in 627 Posts
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: How to delete QwtPlotMarker Objects of QMap<int, QList<QwtPlotMarker *> >

    If your code is exactly as you have copied it here, you are missing the closing ">" on the QMapIterator declaration, which means that the compiler never gets a definition for "i", which results in the second error.

  3. #3
    Join Date
    Jul 2015
    Posts
    87
    Thanks
    1
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to delete QwtPlotMarker Objects of QMap<int, QList<QwtPlotMarker *> >

    shame on me , you are right... now it's working.

    Stefan

Similar Threads

  1. How to delete QMap ?
    By lwz in forum Qt Programming
    Replies: 3
    Last Post: 28th September 2014, 13:38
  2. Replies: 1
    Last Post: 6th February 2014, 08:28
  3. Replies: 0
    Last Post: 25th June 2009, 08:17
  4. Proper way to delete a QMap
    By jano_alex_es in forum Newbie
    Replies: 2
    Last Post: 16th June 2009, 10:26
  5. How to use QMap::remove() to delete some item?
    By jedychen in forum Qt Programming
    Replies: 5
    Last Post: 18th September 2008, 07:29

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.