I just make a my custom style. In my QStyle, I fillrec itemviewrow on drawPrimitive function. Oh, yes I use this style just for my QTreeView..

Qt Code:
  1. model=new MyModel();
  2. ui->treeView->setModel(model);
  3. ui->treeView->setStyle(new TreeStyle());
To copy to clipboard, switch view to plain text mode 

In MyModel I tried set backgroud color for a row with Qt::BackgroundColorRole. But I don't understand why not work. If I remove setStyle from my treeView, Qt::BackgroundColorRole will work..

Qt Code:
  1. //TReeStyle COde
  2. void TreeStyle::drawPrimitive(PrimitiveElement element, const QStyleOption* option,
  3. QPainter* painter, const QWidget* widget) const
  4. {
  5. if (element == PE_PanelItemViewRow || element == PE_PanelItemViewItem)
  6. {
  7. painter->fillRect(option->rect, option->palette.highlight());
  8. }
  9. .......................
  10. .......................
To copy to clipboard, switch view to plain text mode 


Qt Code:
  1. //MyModel Code
  2. if (role == Qt::BackgroundColorRole)
  3. {
  4. .......................
  5. .......................
  6. return qVariantFromValue(QColor(255, 186, 186));
  7.  
  8. }
To copy to clipboard, switch view to plain text mode 

This is normal ? I can't use booth QStyle and Model for QTreeView ?