c++ - Value disappears from QVector -
i have qmap
qvector
inside:
qmap<qstring, qmap<qgraphicsview*, qvector<float>>> graphs;
i'm trying execute code:
qvector<float>* graphvalues = &(graphs.values()[i - values.count()].values()[0]); graphvalues->push_back(1234); qdebug() << "=== debug messages ===\r\n"; qdebug() << "i - values.count() = " << - values.count(); qdebug() << "graphvalues = " << graphvalues; qdebug() << "*graphvalues = " << *graphvalues; qdebug() << "graphs = " << graphs; qdebug() << "graphs.values()[i - values.count()].values()[0] = " << graphs.values()[i - values.count()].values()[0];
it gives me output:
i - values.count() = 0 graphvalues = 0x2000e90 *graphvalues = qvector(1234) graphs = qmap(("tempgraph", qmap((qgraphicsview(0x1fb1920) , qvector() ) ) )) graphs.values()[i - values.count()].values()[0] = qvector()
so, value? using pointer wait value in graphs
, disappears.
qmap::values()
method returns temporary object. cannot change original data, changing it. should use iterators, or qmap::operator[]
somehow.
Comments
Post a Comment