Results 1 to 11 of 11

Thread: QStringList ......how to ignore a string

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Posts
    51
    Thanks
    7

    Default Re: QStringList ......how to ignore a string

    Quote Originally Posted by sumsin
    make a sub-function

    Qt Code:
    1. bool isNameExistInList(QStringList &list, QString &name) {
    2. for(QStringList::Iterator it = list.begin(); it != list.end(); ++it ) {
    3. if(name == *it) {
    4. return TRUE;
    5. }
    6. }
    7. return FALSE;
    8. }
    To copy to clipboard, switch view to plain text mode 

    then use this function at the time of insertion of strings
    Qt Code:
    1. if(!isNameExistInList(yourList, "john_1") {
    2. yourList.append("john_1")
    3. }
    4.  
    5. and so on...
    To copy to clipboard, switch view to plain text mode 
    hello,
    thanx this is working for me but the Qmap is not needed in this situation ..
    Love::Peace

  2. #2
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    76
    Thanked 37 Times in 32 Posts

    Default Re: QStringList ......how to ignore a string

    or

    Qt Code:
    1. if( ! list.contains( name ) ) {
    2. list << name;
    3. }
    To copy to clipboard, switch view to plain text mode 
    We can't solve problems by using the same kind of thinking we used when we created them

Similar Threads

  1. ignore following link in anchorClicked()
    By jh in forum Qt Programming
    Replies: 4
    Last Post: 16th July 2006, 16:33
  2. QStringList with Signal/Slot
    By Sivert in forum Qt Programming
    Replies: 4
    Last Post: 3rd May 2006, 20:34
  3. Cannot queue arguments of type 'QStringList'
    By vfernandez in forum Qt Programming
    Replies: 2
    Last Post: 19th April 2006, 20:48
  4. How to get size (length, width ....) of string or char
    By Krishnacins in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2006, 09:55
  5. need help to classify some QStringList
    By patcito in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 21:24

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
  •  
Qt is a trademark of The Qt Company.