PDA

View Full Version : Problem regarding QVector



sudheer168
6th December 2008, 10:51
Hi ,I am working on Qt4.4.I came across one problem with QVector.I declared a vector containing another vector of type QString.


QVector<QVector<QString> *>mainvec;


Now I want to insert data into vector ie I want to insert 50*50 data into vector mainvec .for that the code i used is



1 for (int i = 0; i < 50; ++i)
2 for (int j = 0; j < 50; ++j)
3 data[i]->push_back("data");


if I do this my execution was breaking when it comes to the line 3.
So please help me to solve the problem

With Regards,
Sudheer.

caduel
6th December 2008, 11:56
i) you insert into a QVector (*data[i] ) that you never allocated!

ii) just use a QList<QStringList>; that is easier and less error prone.

HTH