[Qt-interest] Extended Selection and the "Current Index" of the selection model
Ellen Kestrel
dragonflykes at gmail.com
Mon Mar 15 03:04:08 CET 2010
I have a stringlist model which has previously used individual-item
selection, and when the use selects an item, information about that item is
displayed on a sidebar. The strings in the stringlist correspond to a list
of objects stored separately from the model but updated appropriately, and
the particular object that has been selected is identified by finding the
object at the [selectionModel->currentIndex ()->row ()] index of said list.
Now, I want to use extended selection with this model, but retain the
display function mentioned above. There are move up/move down functions,
which should then move all selected items up/down one slot in the list -
that's easy enough, but I can't get the view to select the correct indexes
after it's done and the selection model is cleared.
I've tried:
-a loop with selectionModel->select (index,
QItemSelectionModel::SelectCurrent)
which results in only the last item selected
-a loop with selectionModel->select (index, QItemSelectionModel::Select)
likewise
-a loop with selectionModel->select (index, QItemSelectionModel::Toggle)
which works, except that this apparently sets currentIndex to null, and the
display I mentioned before can't be updated. I also tried selecting the
first item with QItemSelectionModel::SelectCurrent and then selecting the
rest with Toggle, but currentIndex is still null. I'm guessing if I select
the *last* item with SelectCurrent, all the others will become unselected.
When I select items with ctrl+click from the application, the current index
is updated to the last toggled item without clearing the others. How do I
do this in the code?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20100314/d8a8723b/attachment.html
More information about the Qt-interest-old
mailing list