PDA

View Full Version : QComboBox how far customizable?



youkai
17th August 2008, 09:01
Hi. :)

A combo box has a view and a model. I can change the values for the roles of the item data (e.g. Qt::ForegroundRole).

But how to make an item not selectable?

I want to implement some kind of separator to categorize the entries in a combo box.

Is that possible?

Bye

aamer4yu
17th August 2008, 11:01
Simplest way would be to insert "-----------" as data ;)

for the harder way, u can use delegates :)

youkai
17th August 2008, 12:55
I could insert a "-------------------", but it will still be selectable.

jacek
17th August 2008, 14:02
Simply don't return Qt::ItemIsSelectable flag for that separator item.

See QAbstractItemModel::flags().

youkai
17th August 2008, 16:20
Which means, that I have to implement my own model for that combo box?

jacek
17th August 2008, 16:26
Which means, that I have to implement my own model for that combo box?
I thought you already have one. In that case use QComboBox::insertSeparator() instead.