Results 1 to 2 of 2

Thread: Multiple selection ??

  1. #1
    Join Date
    Apr 2011
    Posts
    58
    Thanks
    1

    Default Multiple selection ??

    Hi.

    I implemented a QListwidget with a list of items in a single colum for users to select.
    I wanted to start with default where there are a random number of the items being selected when the program first started.

    My code is
    mysimpleListWidget->setCurrentItem(mysimpleListWidget->item(i));
    // i is the indices for those items I want to select

    When the program starts, only one item is selected. How come? I had already set the mysimpleListWidget to be multiselection.

    Please help.
    Thank you!
    Marc

  2. #2
    Join Date
    Apr 2011
    Posts
    61
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Multiple selection ??

    When you set the current item, you set 1 item per time. So replacing the "old current index".

    Instead of using listWidget->setCurrentItem, do this:

    Qt Code:
    1. QListWidgetItem* item = listWidget->item(i);
    2. if (item) item->setSelected(true);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Multiple selection list in webkit qt
    By swagatdash in forum Newbie
    Replies: 0
    Last Post: 23rd June 2010, 15:51
  2. QMenu Multiple selection problem
    By vajindarladdad in forum Newbie
    Replies: 3
    Last Post: 7th August 2009, 14:32
  3. QGraphicsScene and multiple selection
    By Bill in forum Newbie
    Replies: 1
    Last Post: 4th August 2009, 16:19
  4. QGraphicsView: Moving multiple selection
    By marcel in forum Qt Programming
    Replies: 1
    Last Post: 23rd April 2007, 20:59
  5. Multiple selection in QTextEdit
    By munna in forum Qt Programming
    Replies: 4
    Last Post: 1st July 2006, 08:58

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.