Results 1 to 10 of 10

Thread: Comparing Items In List Box

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Comparing Items In List Box

    You're comparing pointers, not their contents. An item can only be in one list at once, therefore even if items have the same text, they are different items. Try doing something like:
    Qt Code:
    1. if ( ChoosenParam_lb->currentItem() && AvailableParam_lb->currentItem() &&
    2. ChoosenParam_lb->currentItem()->text() == AvailableParam_lb->currentItem()->text() ) ...
    To copy to clipboard, switch view to plain text mode 

    Or better yet:
    Qt Code:
    1. for(QListBoxItem *iter = ChoosenParam_lb->item(0); iter!=0; iter = iter->next()){
    2. delete AvailableParam_lb->findItem(iter->text(), Qt::ExactMatch);
    3. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 15th February 2007 at 13:35. Reason: wrapped too long line

Similar Threads

  1. Get Visible Items from the QListWidget
    By srj in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 20:13
  2. QGraphicsItem problem - how to save items info ??
    By aamer4yu in forum Qt Programming
    Replies: 3
    Last Post: 17th October 2006, 12:17
  3. delete items from list box
    By vvbkumar in forum Qt Programming
    Replies: 4
    Last Post: 23rd June 2006, 19:08
  4. Selective highlighting of Items
    By Kapil in forum Qt Programming
    Replies: 3
    Last Post: 26th May 2006, 12:20
  5. Replies: 3
    Last Post: 10th April 2006, 19:04

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.