View Full Version : need help to classify some QStringList

17th February 2006, 20:35
I have a list which contains references and another contains prices of each reference. There are some duplicates. It looks like this:

QStringList refList;
QStringList priceList;

{code to fill each list}

I want to get the quantity of each reference and get the price of the sum of each duplicate so to get the result into two QStringList:

QStringList refListWithOutDuplicates;
QStringList priceList;

Any idea what's the best way to do this with Qt?

Thanx in advance


17th February 2006, 21:01
Could you explain a bit more? An example would be helpful.

17th February 2006, 21:49
Ok here are the two lists I have to begin with:

QStringList refList; // {'x','y','z','t','u','x','t'}
QStringList priceList; // {'pricex','pricey','pricez','pricet','priceu','pri cex','pricet'}

Those are the three list I want to get ( I added the quantity list) :

QStringList refListWithOutDuplicates; //{'x','y','z','t','u'}
QStringList priceList; // {'pricex','pricey','pricez','pricet','priceu'}
QStringList qtyOfEachRef; // {'qty_of_x','qty_of_y','qty_of_z','qty_of_t','qty_ of_u'}

update: by quantity I mean number of iteration of each ref.

Thanx in advance

17th February 2006, 22:24
http://doc.trolltech.com/4.0/qlist.html#count maybe?


and repeat...