I\'m creating a styled QTreeView using double-dispatch to resolve specific delegate for data items, which is working great. I subclassed the delegates from QStyledItemDelegate
Different styles can't be selected that way. The properties for selecting the style sheet rule are taken from a QWidget (a QTreeView in this case), not a delegate. The delegate is not a widget, and there isn't a widget representing individual items. Your example can show this by adding a print where the style is obtained from the widget:
style = opt.widget.style()
print opt.widget
It will show that the widget for the style a QTreeView. Since the widget is the same for both delegates, it can't have a role setting that is two values.
Even though the style sheet is written so that it looks like the role is associated with an item, the rule selection is like it was written as:
QTreeView[role="title"]::item:selected