[Interest] Any idea why QAbstractItemView::selectedIndexes() is protected?

K. Frank kfrank29.c at gmail.com
Tue Jul 3 17:02:41 CEST 2012

Hello André!

Thanks for the further explanation.

On Tue, Jul 3, 2012 at 10:10 AM, André Somers <andre at familiesomers.nl> wrote:
> Op 3-7-2012 15:48, K. Frank schreef:
>> Hi André!
>> Thank you for the reply and the pointer to QItemSelectionModel.
>> On Tue, Jul 3, 2012 at 2:06 AM, André Somers <andre at familiesomers.nl> wrote:
>>> ...
>>> I don't know exactly, but the public API for manipulating selections is
>>> QItemSelectionModel.
> ...
> Keep in mind that views _have_ an item selection, but they are not quite
> bound to them.

Ah, I missed that.

Just to check that I understand:  If I don't do anything special by hand
(that is, I don't fiddle with selection machinery, or call anything like
setSelectionModel), then if I call

   QAbstractItemView::selectionModel ()

I get a pointer to the view's "built-in" selection model, and it will tell me
(among other things) which items in the view are currently selected?

If this is the case I should be considering using selectionModel(), and
the fact that selectedIndexes() is protected doesn't really matter.

> The current design makes it possible, for instance, to
> easily share the item selection between two or more views by simply
> setting the same QItemSelectionModel on multiple views.

Yes, thank you.  This is all making more sense now.

> André

Thanks for sorting this out for me.

K. Frank

More information about the Interest mailing list