title: Set size for a cell in QTreeView
body: <p>I need to set:</p>
  
  <pre><code>-minimum height for a cell in QTreeView (25px)
  -the height and width to fit with the content of each cell.
  </code></pre>
  
  <p>I know that we can do it with sizeHint() in Delegate or with sizeHintRole in Model but still can not imagine how the functions should look like. This is paint() in my Delegate:</p>
  
  <pre><code>const int marginLeft = 10; // margin between text in each cell with the left border
  const int marginLeftFirstColumn = 20; //margin between text and the left border in the first column
  const int marginRight = 10;
  
  void TableDelegate::paint( QPainter *p_painter, const QStyleOptionViewItem &amp;p_option, const QModelIndex &amp;p_index ) const
  {
    QStyleOptionViewItem option = p_option;
  
    TableDataRow::Type type = static_cast&lt;TableDataRow::Type&gt;( p_index.data( Qt::UserRole ).toInt() );
  
    QString text = p_index.data( Qt::DisplayRole ).toString();
    QFont font = p_painter-&gt;font();
    int col = p_index.column();
  
    switch ( type )
    {
       case TableDataRow::Type::Data:
       {
          font.setWeight( QFont::Normal );
          p_painter-&gt;setFont( font );
          if ( col == 0 )
          {
             option.rect.setRect( option.rect.left() + marginLeftFirstColumn, option.rect.top(), option.rect.width() - marginRight, option.rect.height() );
          }
          else
          {
             option.rect.setRect( option.rect.left() + marginLeft, option.rect.top(), option.rect.width() - marginRight, option.rect.height() );
          }
          break;
       }
       case  TableDataRow::Type::MainCaption:
       {
          p_painter-&gt;fillRect( p_option.rect, Qt::gray ); //draw background
          font.setWeight( QFont::Bold );
          p_painter-&gt;setFont( font );
          option.rect.setRect( option.rect.left() + marginLeft, option.rect.top(), option.rect.width() - marginRight, option.rect.height() );
          break;
       }
    }
    p_painter-&gt;drawText( option.rect, Qt::AlignVCenter | Qt::TextWordWrap, text );
  }
  
  QSize TableDelegate::sizeHint( const QStyleOptionViewItem &amp;p_option, const QModelIndex &amp;p_index ) const //this function to compensate the alignment
  {
    QSize size = QStyledItemDelegate::sizeHint( p_option, p_index );
    if ( p_index.column() == 0 )
       {
          size.setWidth( size.width() + marginLeftFirstColumn );
       }
       else
       {
          size.setWidth( size.width() + marginLeft );
       }
    return size;
  }
  </code></pre>
  
  <p>Could you guys help me with data() function in Model and update sizeHint() in Delegate?</p>