Results 1 to 3 of 3

Thread: QListWidget multiselection indexes

  1. #1
    Join Date
    Sep 2009
    Location
    phoenix, AZ
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default QListWidget multiselection indexes

    Hi,

    I'm using a QlistWidget with Multiselection.... is that possible to get the indexes of selected items in the List, the selectedItems() return a list of selected items but l only need the indexes ( row selected).

    thanks,

    Michael

  2. #2
    Join Date
    Apr 2010
    Posts
    20
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QListWidget multiselection indexes

    Hi friend
    There's 2 methods in QListWidget: selectedItems and selectedIndexes. I guess that second one can help you
    hugs

  3. #3
    Join Date
    Sep 2009
    Location
    phoenix, AZ
    Posts
    41
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QListWidget multiselection indexes

    this method is private but googling that l found a thread: "Retrieve selected indices from a QListWidget"

    the solution is:
    QModelIndexList indexes = listWidget->selectionModel()->selectedIndexes();
    std::vector<int> indexList;
    foreach(QModelIndex index, indexes)
    indexList.push_back(index.row());

    thanks,

    Michael

Similar Threads

  1. Count indexes in QListView
    By been_1990 in forum Qt Programming
    Replies: 5
    Last Post: 17th December 2009, 19:21
  2. How to mess QMdiArea indexes?
    By Raccoon29 in forum Qt Programming
    Replies: 2
    Last Post: 21st April 2008, 21:46
  3. problem with indexes
    By MarkoSan in forum Qt Programming
    Replies: 5
    Last Post: 10th December 2007, 14:55
  4. QListView multiSelection
    By cristiano in forum Qt Programming
    Replies: 3
    Last Post: 19th December 2006, 23:41
  5. Rubberband painting on multiselection in a list view
    By SkripT in forum Qt Programming
    Replies: 10
    Last Post: 19th March 2006, 11:13

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.