Results 1 to 4 of 4

Thread: need help to classify some QStringList

  1. #1
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default need help to classify some QStringList

    I have a list which contains references and another contains prices of each reference. There are some duplicates. It looks like this:

    Qt Code:
    1. QStringList refList;
    2. QStringList priceList;
    3.  
    4. {code to fill each list}
    To copy to clipboard, switch view to plain text mode 

    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:

    Qt Code:
    1. QStringList refListWithOutDuplicates;
    2. QStringList priceList;
    To copy to clipboard, switch view to plain text mode 

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


    Thanx in advance

    Pat

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: need help to classify some QStringList

    Could you explain a bit more? An example would be helpful.

  3. #3
    Join Date
    Jan 2006
    Posts
    46
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: need help to classify some QStringList

    Ok here are the two lists I have to begin with:

    Qt Code:
    1. QStringList refList; // {'x','y','z','t','u','x','t'}
    2. QStringList priceList; // {'pricex','pricey','pricez','pricet','priceu','pricex','pricet'}
    To copy to clipboard, switch view to plain text mode 

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

    Qt Code:
    1. QStringList refListWithOutDuplicates; //{'x','y','z','t','u'}
    2. QStringList priceList; // {'pricex','pricey','pricez','pricet','priceu'}
    3. QStringList qtyOfEachRef; // {'qty_of_x','qty_of_y','qty_of_z','qty_of_t','qty_of_u'}
    To copy to clipboard, switch view to plain text mode 

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

    Thanx in advance
    Pat

  4. #4
    Join Date
    Jan 2006
    Location
    Athens - Greece
    Posts
    219
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: need help to classify some QStringList

    http://doc.trolltech.com/4.0/qlist.html#count maybe?
    Qt Code:
    1. qtyOfEachRef.append(QString("%1_of_%2").arg(refList.count(QString("x"))).arg("x"));
    To copy to clipboard, switch view to plain text mode 
    and repeat...

Similar Threads

  1. QStringList
    By jaca in forum Qt Programming
    Replies: 5
    Last Post: 17th May 2008, 11:12
  2. QStringList scope problem
    By ht1 in forum Qt Programming
    Replies: 5
    Last Post: 30th November 2007, 20:44
  3. Translating a QStringList
    By ^NyAw^ in forum Qt Programming
    Replies: 5
    Last Post: 18th January 2007, 12:06
  4. QStringList in QObject::connect
    By DPinLV in forum Qt Programming
    Replies: 6
    Last Post: 6th September 2006, 18:01
  5. Cannot queue arguments of type 'QStringList'
    By vfernandez in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2006, 21:48

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.