Results 1 to 3 of 3

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

Threaded View

Previous Post Previous Post   Next Post Next Post
  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 08:38.

Similar Threads

  1. Proper way to delete a QMap
    By jano_alex_es in forum Newbie
    Replies: 4
    Last Post: 28th February 2020, 18:31
  2. How to delete QMap ?
    By lwz in forum Qt Programming
    Replies: 3
    Last Post: 28th September 2014, 14:38
  3. Replies: 1
    Last Post: 6th February 2014, 09:28
  4. Replies: 0
    Last Post: 25th June 2009, 09:17
  5. How to use QMap::remove() to delete some item?
    By jedychen in forum Qt Programming
    Replies: 5
    Last Post: 18th September 2008, 08: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.