PDA

View Full Version : QComboBox: disabling an item in the combobox menu



zgulser
5th January 2011, 12:02
Hi,

Is there an easy way to disable some of the items(or row data or whatever) in the combobox's menu when one of them is selected?

Regards

high_flyer
5th January 2011, 15:23
I don't understand what 'disabling' in this context means... the item is in the list, so what would "disabling" it do exactly?

tbscope
5th January 2011, 15:31
You can create a custom item delegate and react on some user data to paint some items in lighter grey (or wathever) and make it so you can't select them.
How this will work with editable comboboxes... I don't know.
You probably want to subclass QComboBox too to alter the behaviour of the signals and slots with respect to those disabled items.

A better way would be to just remove those items from the list.

zgulser
5th January 2011, 22:08
@high_flyer: it means they can be seen in the menu when the combobox clicked but somehow can't be selected by users. I wonder the somehow part..ok now?

@tbscope: I wish I could remove them, but it won't work for me. I think they should be seperate classes so that they can be modified in an agile way just like QListWidget item.

Maybe css solve the problem which I don't think so.

high_flyer
5th January 2011, 22:15
I too think that the proper way is through a custom delegate.
CSS or style sheets will only change the look and feel but not the behaviour.