QComboBox different Item value when selected and in dropDown

310 Views Asked by At

how to easily make duo QAbstractListModel × QComboBox (not reimplementing QComboBox)

so that item representation on selection differs from one on DropDownList

Background:

I have model (inherited from QAbstractListModel) which flattens other model derived QAbstractItemModel, which however represents tree structure

Items are in the same order as they are in the tree model

I wanted to indent them, for better orientation in selection,

however once selected, it looks strange, when the sole selected item is indented

i.e. having this structure (verbatim how I assume it being seen in QComboBox DropDown list

parent 1
 -> child 1.1
 ---> subChild 1.1.1
 -> child 1.2
 -> child 1.3
 ---> subChild 1.3.1
 ---> subChild 1.3.2
parent2

and once selected, I want it to show only

subChild 1.3.2

now it shows

---> subChild 1.3.2

as far as I know, both representations go through model::data(index, role=Qt::DisplayRole), so I can't differentiate them there

PS: In case there is some QComboBox-like directly working with models containing trees, even better

0

There are 0 best solutions below