I'm making the gui for my QGIS3 plugin using PyQT5 and QT designer. I have a very long list of items in a QComboBox
and I need the user to be able to select one or more items. I know that QComboBox
allows only single selection, so I thought that I can use QListWidget
. The problem is that the list of selectable items is very long and I'd need a dropdown menu or something similar.
Is there a way to style a QListWidget
like a QComboBox
or to allow a multiple selection using QComboBox
?
EDIT: I added an immage of my GUI. This is a long list and, as you can see, it's the reason why I can't use QListWidget
or QTableWidget
. A dropdown checkbox group should be perfect and I'm surprised that QT doesn't make this available.
Best Answer
For anyone interested, here is an implementation of a CheckableComboBox.
Usage
Result
Edit
QGIS defines its own QgsCheckableCombobox, which is unfortunately broken (https://github.com/qgis/QGIS/issues/28658).
It relies on the QCombBox activated signal to toggle on/off its items. The problem is that this signal is emitted when the combobox is opened and there's a single selected item, which is NOT the currentIndex
It's however possible to fix it, albeit in a slightly hackish way