Results 1 to 15 of 15

Thread: How can I remove a list of selected items in the QListView in QT 4.6.?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Wiki edits
    5

    Default Re: How can I remove a list of selected items in the QListView in QT 4.6.?

    Something like that should work. (Idea: sort the list and begin at the end to ensure that the indices stay valid):
    Qt Code:
    1. YOURVIEW->setUpdatesEnabled(false);
    2. QModelIndexList indexes = ui.listview_files->selectionModel()->selectedIndexes();
    3. indexes.sort();
    4. for (i = indexes.count() - 1; i > -1; --i)
    5. model->removeRow(indexes.at(i).row());
    6. YOURVIEW->setUpdatesEnabled(true);
    To copy to clipboard, switch view to plain text mode 

  2. The following user says thank you to Lykurg for this useful post:

    saa7_go (26th July 2010)

Similar Threads

  1. Remove selected rows from a QTableView
    By niko in forum Qt Programming
    Replies: 4
    Last Post: 3rd March 2016, 13:49
  2. Replies: 6
    Last Post: 27th March 2010, 06:42
  3. QListview set selected item
    By Freeman551 in forum Qt Programming
    Replies: 1
    Last Post: 25th December 2009, 01:17
  4. Replies: 5
    Last Post: 2nd April 2007, 09:57
  5. Remove selected QListWidgetItem
    By xgoan in forum Newbie
    Replies: 7
    Last Post: 28th September 2006, 15:42

Tags for this Thread

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.