I’ve created a custom model, view (tree) and delegate and everything seems to be working OK with one minor issue. Some of the cells of the tree are combo boxes. The combo boxes work as expected when selected by the user (custom createEditor, setEditorData and setModelData delegate methods). The issue I have is the down arrow is only displayed when the cell is selected. I would like the down arrow to be displayed all the time.
I’m not sure which method is control’s the display of the down arrow. Does it come from the model data (maybe the decorationrole) or is it the paint method of the delegate. Note I’m not using any style sheets.
Update:
Found the solution I was after here. Basically ended up with the following in the paint method of my custom delegate.
QStyleOptionComboBox comboBoxOption;
comboBoxOption.rect = option.rect;
comboBoxOption.state = option.state;
comboBoxOption.state |= QStyle::State_Enabled;
comboBoxOption.editable = false;
comboBoxOption.currentText = index.data(Qt::DisplayRole).toString();
QApplication::style()->drawComplexControl(QStyle::CC_ComboBox, &comboBoxOption, painter);
QApplication::style()->drawControl(QStyle::CE_ComboBoxLabel, &comboBoxOption, painter);