QComboBox Item Disable
-
I am trying to disable certain items in a QComboBox when a user selects a certain item from another QComboBox is there an easy way of doing this?
-
The proper way of doing this would be to provide a custom model for combo box and clear the ItemIsSelectable and ItemIsEnabled flags for the items you want to disable.
If you're not afraid of undocumented hacks that can break at any given point in the future there's also "this dirty dirty trick":http://theworldwideinternet.blogspot.com/2011/01/disabling-qcombobox-items.html based on current internal implementation of default model:
@
// disable item
ui->comboBox->setItemData(index, 0, Qt::UserRole - 1);
// enable item
ui->comboBox->setItemData(index, 33, Qt::UserRole - 1);
@