title: Some cells in QtableView are not repainted automatically after a clicking on a table cell
body: <p>I'm using a QTableView in the implementation of an interactive board game. Images are to be displayed in the cells of the table. I'm using a QStyledItemDelegate with a paint function to draw the images inside the table cells. </p>
  
  <p>As the images should be displayed only in certain cells of the table and updated when a user clicks on a table cell, an double int array is used which is of the same dimensions as the table. Depending on the values the the array, the painter should draw images in specific cells of the table. Initially there are only 4 images inside 4 cells of the table and as the user clicks on a cell in the table, the array is updated which should consequently mean that whats drawn and displayed inside the cells of rthe table should be changed.</p>
  
  <p>Normally the user clicks on an empty (white) cell which is updated successfully and the specific image is shown in the cell. However, if there are other cells which contain an image and should be updated, the update is not shown, although the double int array is updated. I also saw a weird thing, that is when I click on the cells in which their display should have been updated, the update happens. This of-course occurs regardless of how I update when someone clicks on a cell.</p>
  
  <p>I tried to first erase whats inside the cell before redrawing, but its still not working. Does the delegate runs continuously in a thread and the painter function is called with the index of each cell in the table? I do not get how an update on a cell containing an Image does not update automatically although the painter should have redrawn the cell's area and it occurs only after the a click on the cell has been made. Or its cus a new painter is called to the painter's function each time?!</p>
  
  <p>Well, here is my implementation of the painter's function of the delegate:</p>
  
  <pre><code>void Sphere::paint(QPainter *painter, const QStyleOptionViewItem &amp;option,
                            const QModelIndex &amp;index) const
   {
       if(tb1[index.row()][index.column()] == 1)
       {
           QImage Q1("Red Sphere.jpg");
  
       QRectF source(0.0, 0.0, 72.0, 70.0);
  
       painter-&gt;eraseRect(option.rect);
  
       if (option.state &amp; QStyle::State_Selected)
               painter-&gt;fillRect(option.rect, option.palette.highlight());
  
       painter-&gt;drawImage(option.rect, Q1, source);
  
       }
       else if(tb1[index.row()][index.column()] == 2)
       {
           QImage Q1("Blue Sphere.jpg");
  
       QRectF source(0.0, 0.0, 72.0, 70.0);
  
       painter-&gt;eraseRect(option.rect);
  
       if (option.state &amp; QStyle::State_Selected)
               painter-&gt;fillRect(option.rect, option.palette.highlight());
  
  
       painter-&gt;drawImage(option.rect, Q1, source);
  
       }
       else 
       {
           painter-&gt;eraseRect(option.rect);
  
           QStyledItemDelegate::paint(painter, option, index);
       }
    } 
  </code></pre>
  
  <p>I can give you any more info if u needed to solve my problem. Thanks in advance.</p>