Results 1 to 5 of 5

Thread: qlistwidget count of selected items

  1. #1
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default qlistwidget count of selected items

    I know you can use count() on a QListWidget to get the count of the items in the widget.

    Is there a better way to get the count of only the selected items in the widget, rather than using QListWidget::selectedItems () and then getting the count of that list?

  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: qlistwidget count of selected items

    What's wrong with using selectedItems() and count()?

  3. #3
    Join Date
    Oct 2006
    Location
    Hawaii
    Posts
    130
    Thanks
    48
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qlistwidget count of selected items

    From what I gathered, selectedItems() makes a copy of the selected items does it not? and then you get a count of that. I was just seeing if there was a more efficient way to do it, that wouldn't need to make a copy.

  4. #4
    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: qlistwidget count of selected items

    No, it creates a list of pointers. It doesn't copy any objects.

  5. The following user says thank you to wysota for this useful post:

    tpf80 (23rd May 2007)

  6. #5
    Join Date
    May 2006
    Location
    Bangalore,India
    Posts
    235
    Thanks
    7
    Thanked 25 Times in 24 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default Re: qlistwidget count of selected items

    How to Copy all selected item in clipboard ?

Similar Threads

  1. QListWidget help please
    By munna in forum Qt Programming
    Replies: 5
    Last Post: 28th November 2006, 12:16
  2. Get Visible Items from the QListWidget
    By srj in forum Qt Programming
    Replies: 4
    Last Post: 22nd November 2006, 20:13
  3. Qt 4.2: QListWidget changes size of its items
    By KingFish in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2006, 11:06
  4. [Qt4]: Adding centered items in QListWidget
    By Jojo in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2006, 20:04
  5. Getting all items of a QListWidget
    By Codepoet in forum Qt Programming
    Replies: 3
    Last Post: 17th January 2006, 22:52

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.