PDA

View Full Version : Item Selection in QListWidget



mclark
11th February 2008, 23:20
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...

addLst->selectionModel()->select( index, QItemSelectionModel::Select );
...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.


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

Thanks

jpn
12th February 2008, 09:39
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().

mclark
12th February 2008, 16:53
Thanks jpn, I can't believe I missed that :o