Results 1 to 4 of 4

Thread: Getting all items of a QListWidget

  1. #1
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Getting all items of a QListWidget

    Hi!

    I'm currently using the following code to get all items in a QListWidget:
    Qt Code:
    1. QList<QListWidgetItem*> items = list->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard);
    To copy to clipboard, switch view to plain text mode 
    Is there a better / faster way? I just can't find a allItems() call.

    Codepoet

  2. #2
    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: Getting all items of a QListWidget

    What would allItems() return?
    There is a count() member so you can loop through the QListWidget items and add them to your container.

  3. #3
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    85
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Getting all items of a QListWidget

    allItems would return a QList<QListWidgetItem*> containing every QListWidgetItem which is at the moment in my QListWidget without forcing me to do hundreds / thousands of calls to item(). Just something like selectedItems.

    But I'll try your suggestion

  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: Getting all items of a QListWidget

    Quote Originally Posted by Codepoet
    ... forcing me to do hundreds / thousands of calls to item()...
    My suggestion will also do that I'm afraid

Similar Threads

  1. How to make QListWidget items editable?
    By montylee in forum Qt Programming
    Replies: 14
    Last Post: 3rd October 2008, 09:57
  2. Replies: 1
    Last Post: 5th September 2008, 23:54
  3. Get Visible Items from the QListWidget
    By srj in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 20:13
  4. Qt 4.2: QListWidget changes size of its items
    By KingFish in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 11:06
  5. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.