Search code examples
c++qtmulti-selectqlistwidget

QListWidget MultiSelection always does multiple selections


I'm using a QListWidget and enabled multiple selections:

mReferenceList->setSelectionMode(QAbstractItemView::MultiSelection);

The problem is, that this mode doesn't behave as is expected as standard on Windows. Normally a listbox with mulötiple selections works in such a way that you click on item, click another and the previous one is unselected. Only when you use SHIFT+LButton or CTRL+LButton are multiple items selected.

Currently the listbox now selects one item after the other, when I click on several items. Is there some setting that enables this beahviour?

I'm using Qt 5.2 with MingW.


Solution

  • According to the QAbstractItemView::MultiSelection mode description:

    ...the selection status of that item is toggled and the other items are left alone.

    I think the QAbstractItemView::ExtendedSelection mode is what you expect, because for it "...the selection is cleared and the new item selected".