PDA

View Full Version : How to make QComboBox as multiselect in Qt



pranjali nagpure
27th September 2016, 14:21
Hello

Please tell me how to select multiple items in combo box.


Regards
pranjali nagpure

d_stranz
28th September 2016, 15:48
From the QComboBox documentation:


Note that you cannot alter the SelectionMode of the view(), e.g., by using setSelectionMode().

QComboBox is single selection only. Think about it - if you could make it multiple selection, how would you display the result once the drop-down is closed?

I suggest you substitute QListWidget or QListView in your GUI if you want multiple / extended selection mode.

Ginsengelf
29th September 2016, 07:55
Hi, Qwt has QxtCheckComboBox (http://libqxt.bitbucket.org/doc/0.6/qxtcheckcombobox.html) for this.

Ginsengelf

Camryn64
4th October 2016, 02:22
ok. I was facing the same issue.. thanks for post

d_stranz
4th October 2016, 03:14
@Ginsengelf means "Qxt", not "Qwt". In any case, it is based on Qt4, is no longer maintained, and as the Qxt website (https://bitbucket.org/libqxt/libqxt/wiki/Home) itself says:


Qxt will likely not work with newer Qt versions due to usage of internal api. We recommend that you pick out the parts you want instead of using the entire libqxt.

So, depending on how much of QxtCheckComboBox is based on undocumented internals of Qt, and how much those internals have changed between Qt4 and Qt5, you may not be able to use it at all.

The biggest change from Qt4 -> Qt5 is the removal of all OS-dependent GUI code from widget implementations into window-system-specific plugins. Since the combo box is a GUI widget, the Qt4 internal implementation is probably greatly different.

You might have better luck finding something in KDE. Check out the qinclude.org (http://inqlude.org/) site for all sorts of Qt libraries.