title: Changing the row background color of a QTreeView does not work
body: <p>I have a <code>QTreeView</code> and want different background colors for rows, depending on their content. To achieve this, I derived a <code>class MyTreeView</code> from <code>QTreeView</code> and implemented the paint method as follows:</p>
  
  <pre><code>    void MyTreeView::drawRow (QPainter* painter,
                                const QStyleOptionViewItem&amp; option,
                                const QModelIndex&amp; index) const
      {
        QStyleOptionViewItem newOption(option);
  
        if (someCondition)
        {
          newOption.palette.setColor( QPalette::Base, QColor(255, 0, 0) );
          newOption.palette.setColor( QPalette::AlternateBase, QColor(200, 0, 0) );
        }
        else
        {
          newOption.palette.setColor( QPalette::Base, QColor(0, 0, 255) );
          newOption.palette.setColor( QPalette::AlternateBase, QColor(0, 0, 200) );
        }
  
        QTreeView::drawRow(painter, newOption, index);
      }
  </code></pre>
  
  <p>Initially, I set <code>setAlternatingRowColors(true);</code> for the QTreeView.</p>
  
  <p><strong>My problem:</strong> Setting the color for <strong>QPalette::Base has no effect</strong>. Every second row remains white.</p>
  
  <p>However, setting <strong>QPalette::AlternateBase works as expected</strong>.
  I tried <code>setAutoFillBackground(true)</code> and <code>setAutoFillBackground(false)</code> without any effect.</p>
  
  <p>Are there any hints how to solve this problem? Thank you.</p>
  
  <hr>
  
  <p><em>Remark:</em> Setting the color by adapting <code>MyModel::data(const QModelIndex&amp;, int role)</code> for <code>Qt::BackgroundRole</code> does not provide the desired result. In this case, the background color is used only for a part of the row. But I want to color the full row, including the left side with the tree navigation stuff.</p>
  
  <p><em>Qt Version:</em> 4.7.3</p>
  
  <hr>
  
  <p><strong>Update:</strong>
  For unknown reasons <code>QPalette::Base</code> seems to be opaque.
  setBrush does not change that.
  I found the following workaround:</p>
  
  <pre><code>    if (someCondition)
      {
          painter-&gt;fillRect(option.rect, Qt::red);
          newOption.palette.setBrush( QPalette::AlternateBase, Qt::green);
      }
      else
      {
          painter-&gt;fillRect(option.rect, Qt::orange);
          newOption.palette.setBrush( QPalette::AlternateBase, Qt:blue);
      }
  </code></pre>