your loop must be like these line
Qt Code:
for(i=0;it1!=lis.end();it1++); { out<<(*it1).id; out<<(*it1).name; }To copy to clipboard, switch view to plain text mode
your loop must be like these line
Qt Code:
for(i=0;it1!=lis.end();it1++); { out<<(*it1).id; out<<(*it1).name; }To copy to clipboard, switch view to plain text mode
I couldn't get the for loop to work either, but the following seems to work fine:Qt Code:
QList<circle* >::iterator it1=lis.begin(); while(it1!=lis.end()) { out << (*it1)->id << (*it1)->name; ++it1; }To copy to clipboard, switch view to plain text mode
EDIT: The following worked after I ran make clean and qmake:Qt Code:
QList<circle* >::iterator it1; for(it1=lis.begin();it1!=lis.end();++it1) { out<< (*it1)->id << (*it1)->name; }To copy to clipboard, switch view to plain text mode
or you could do away with the iterator and use:Qt Code:
foreach(circle *c, lis) out << c->id << c->name;To copy to clipboard, switch view to plain text mode
Last edited by norobro; 21st August 2011 at 23:04.
thank you very much i've found the problem the semicolon after the for loob caused the problem so we are accessing the end end element
Qt Code:
void soso::go() { throw " cannot open file ! "; int i=0; QList<circle*>::iterator it1 =lis.begin(); for(i=0;it1!=lis.end();it1++); { out<<(*it1)->id; // segmentation error in the runtime out<<(*it1)->name; } }To copy to clipboard, switch view to plain text mode
Bookmarks