is it possible to disable a single item (or more if I so choose) in a QCombobox.
I do not want to remove an item from the list just gray it out or so it cant be selected.
is it possible to disable a single item (or more if I so choose) in a QCombobox.
I do not want to remove an item from the list just gray it out or so it cant be selected.
May be you can try -
Setting your own view ( QListWidget ) to the combobox and then disabling the items you want with setItemFlags.
Other way would be by accessing the item through combobox's model and setting the enabled flag. Am looking for a way to do this.. will post if I find.
Till then you can try the above method
Added after 14 minutes:
Well, found something,-
Qt Code:
{ setData((int)flags, Qt::UserRole - 1); }To copy to clipboard, switch view to plain text mode
So you can try the following -
QComboBox::setItemData(row,false, Qt::UserRole - 1);
I guess it should work...
Last edited by aamer4yu; 19th March 2012 at 13:41.
you can edit the color(i.e. for convinience gray tones) of your item you disabled and doing nothing upon it's selection.
Bookmarks