Results 1 to 3 of 3

Thread: Item Selection in QListWidget

  1. #1
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Question Item Selection in QListWidget

    I am using a QListWidget and would like to programatically select one or more row entries in this widget. In reading the Qt 4.2.2 documentation it appears I must call...
    Qt Code:
    1. addLst->selectionModel()->select( index, QItemSelectionModel::Select );
    To copy to clipboard, switch view to plain text mode 
    ...where index is either a QModelIndex or QItemSelection object.

    While I know what the row index is that I want to select, I don't know how to translate that into either QModelIndex or QItemSelection objects. There is a conceptual void here for me.

    1. Am I attempting to select in the correct manner?
    2. How do I translate my row index into the correct Qt object?

    Thanks

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Item Selection in QListWidget

    Quote Originally Posted by mclark View Post
    Am I attempting to select in the correct manner?
    Well, there's a convenience method available too, see QListWidgetItem::setSelected().

    How do I translate my row index into the correct Qt object?
    See QListWidget::itemFromIndex().
    J-P Nurmi

  3. The following user says thank you to jpn for this useful post:

    mclark (12th February 2008)

  4. #3
    Join Date
    Aug 2006
    Location
    Madison, WI USA
    Posts
    153
    Thanks
    35
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Item Selection in QListWidget

    Thanks jpn, I can't believe I missed that

Similar Threads

  1. QListWidget and selecting an item
    By invictus in forum Newbie
    Replies: 4
    Last Post: 19th June 2007, 11:59
  2. Replies: 1
    Last Post: 19th April 2007, 22:23
  3. QTreeWidget & QListWidget different selection
    By munna in forum Qt Programming
    Replies: 9
    Last Post: 21st July 2006, 06:50
  4. QListWidget selection behavior
    By Arthur in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2006, 14:10
  5. keypress while editing an item in QListWidget
    By Beluvius in forum Qt Programming
    Replies: 3
    Last Post: 4th April 2006, 09:56

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.