title: Get a delegate to set the size of a cell in a QTableView
body: <p>I am using a delegate to display a QPixmap from a QAbstractTableModel in a QTableView, like this:</p>
  
  <pre><code>void LabelDelegate::paint(QPainter *painter, const QStyleOptionViewItem &amp;option, const QModelIndex &amp;index) const
  {
    QPixmap pixmap = index.data(Qt::DisplayRole).value&lt;QPixmap&gt;();
  
    QRect rect = option.rect;
    rect.adjust(rect.width()/3, 0, -rect.width()/3, 0);
    painter-&gt;drawPixmap(rect, pixmap, pixmap.rect());
  }
  </code></pre>
  
  <p>However, I want it to make sure that the cell is big enough to display the whole QPixmap. I tried using the sizeHint function:</p>
  
  <pre><code>QSize LabelDelegate::sizeHint(const QStyleOptionViewItem &amp; option, const QModelIndex &amp; index) const
  {
    std::cout &lt;&lt; "sizeHint()" &lt;&lt; std::endl;
    unsigned int sideLength = 300;
    return QSize(sideLength, sideLength);
  }
  </code></pre>
  
  <p>but it doesn't seem to resize the cell. How would I force the cell size to match the QPixmap size?</p>
  
  <p>Thanks,</p>
  
  <p>David</p>