HappyCoder
19th July 2015, 07:31
Hello,
i try to delete the objects of this QMap:
QMap<int, QList<QwtPlotMarker *> > mapTempMarker;
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:
QMapIterator<int, QList<QwtPlotMarker *> i(mapTempMarker);
while (i.hasNext())
{
i.next();
qDeleteAll( i.value() );
}
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:
class PlotManager::PrivateData
{
public:
PrivateData(){}
~PrivateData()
{
// Necessary, because "delete" deletes only the pointers, but not the objects behind
qDebug() << Q_FUNC_INFO << "Delete Objects";
qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesPressure);
qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesTemperature);
qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesTemperature);
// Delete QMap<int, QList<QwtPlotMarker *> >
QMapIterator<int, QList<QwtPlotMarker *> i(mapTempMarker);
while (i.hasNext())
{
i.next();
qDeleteAll( i.value() );
}
}
QVector<QwtPlotCurve *> curvesPressure;
QVector<QwtPlotCurve *> curvesTemperature;
QMap<int, QList<QwtPlotMarker *> > mapTempMarker;
};
Thx
Stefan
i try to delete the objects of this QMap:
QMap<int, QList<QwtPlotMarker *> > mapTempMarker;
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:
QMapIterator<int, QList<QwtPlotMarker *> i(mapTempMarker);
while (i.hasNext())
{
i.next();
qDeleteAll( i.value() );
}
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:
class PlotManager::PrivateData
{
public:
PrivateData(){}
~PrivateData()
{
// Necessary, because "delete" deletes only the pointers, but not the objects behind
qDebug() << Q_FUNC_INFO << "Delete Objects";
qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesPressure);
qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesTemperature);
qDebug() << Q_FUNC_INFO << "qDeleteAll(curvesPressure)"; qDeleteAll(curvesTemperature);
// Delete QMap<int, QList<QwtPlotMarker *> >
QMapIterator<int, QList<QwtPlotMarker *> i(mapTempMarker);
while (i.hasNext())
{
i.next();
qDeleteAll( i.value() );
}
}
QVector<QwtPlotCurve *> curvesPressure;
QVector<QwtPlotCurve *> curvesTemperature;
QMap<int, QList<QwtPlotMarker *> > mapTempMarker;
};
Thx
Stefan