title: QTableView row styling
body: <p>I have got a QTableView component displaying several types of data in the rows. What I need is to display <strong>each type of row by different color</strong>. My stylesheet looks like this:</p>
  
  <pre><code>RecordSheet::item {
          border: 0px;
          color: black;
          padding: 1px 0px 0px 3px;
  }
  RecordSheet::item:selected, RecordSheet::item:selected:!active {
          background-color: #e8b417;
          color: black;
  }
  </code></pre>
  
  <p>I have two ideas how to achieve this:</p>
  
  <ol>
  <li><p>Use <code>data()</code> method in the model and respond to the <code>Qt::BackgroundColorRole</code>. Unfortunately when I do it, the background color is ignored until I remove the <code>border: 0px;</code> from the stylesheet and when I remove the border, the styleshhet's padding is ignored. Strange...</p></li>
  <li><p>Setup a CSS/QSS class for each type of row and set their colors in the stylesheet. Then use the model to assign a proper class for each type of row. So the stylesheet would look like this:</p>
  
  <pre><code>RecordSheet::item {
      border: 0px;
      color: black;
      padding: 1px 0px 0px 3px;
  }
  RecordSheet::item[class=green_row] {
          background-color: green;
  }
  RecordSheet::item[class=red_row] {
          background-color: red;
  }
  </code></pre>
  
  <p>I like this approach more because it separates content from the appearance, but I don't have any idea how to do it. Maybe using an ItemDelegate?</p></li>
  </ol>
  
  <p>Please, does anybody know a nice and simple solution?</p>
  
  <p>Kind regards and many thanks.</p>
  
  <p>Jan</p>