qt - QStringList "index out of range" -


i trying reverse words withing qstringlist. below code now, keep on getting "index out of range" error. error seem trying use data out of scope, not able figure out problem.

qstring reversed; qstringlist reversedlist; qstringlist list = input.split(" ");  (int i=0;i<list.length(); ++1)   reversedlist[i] = list[list.length() -1 -i];  reversed = reversedlist.join(" ");` 

thanks

your reversedlist empty. have append items, this:

reversedlist.push_back (list[list.length () - 1 - i]); 

naturally, trying access non-existing items via reversedlist[i] not work , throws index-out-out-range error.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -