PDA

View Full Version : QComboBox item disable?



Equilibrium
28th November 2007, 07:55
Hi,

Is ther a way to disable and item in QCombobox?

wysota
28th November 2007, 09:14
I don't think this is possible in Qt3. You'd have to port your project to Qt4.

Equilibrium
28th November 2007, 09:48
not even with subclassing QCombobox?

wysota
28th November 2007, 12:40
I don't think so. You might try by accessing the listBox of the combobox and manipulating its items - for instance calling QListBoxItem::setSelectable() to make items not selectable, but it could be much work and no effects. Feel free to try it, though.

Oleg
28th November 2007, 16:47
A question regarding this topic: how to implement such feature in Qt4? I don't see the way to contol QComboBox items behaviour.

jacek
28th November 2007, 17:02
A question regarding this topic: how to implement such feature in Qt4?
I've never tried it, but probably it will be enough if you unset the Qt::ItemIsSelectable flag for given row in the model used by QComboBox.

wysota
28th November 2007, 17:18
I've never tried it, but probably it will be enough if you unset the Qt::ItemIsSelectable flag for given row in the model used by QComboBox.

I'd say ItemIsEnabled is a more probable candidate.

Oleg
28th November 2007, 18:29
Stupid question, what is the way to set flags for QComboBox items? I can get the model for combobox, but how to change flags of its rows?

wysota
28th November 2007, 18:41
You need to set a custom model on the combobox that will return proper flags.