title: Qt - QIcon in QTableWidget cell
body: <p>I have tried numerous ways to display a QIcon in a QTableWidget cell and I am not sure why it is not working. I have a button that when pressed adds a row to the table. Here is the code...</p>
  
  <pre><code>void MainWindow::pressed()
  {
      QTableWidgetItem *item = new QTableWidgetItem("Hello, world!");
      QTableWidgetItem *icon_item = new QTableWidgetItem;
      QIcon icon("/verified/path/to/icon.png");
      icon_item-&gt;setIcon(icon);
  
      int row = ui-&gt;tableFeed-&gt;rowCount();
      ui-&gt;tableFeed-&gt;insertRow(row);
      ui-&gt;tableFeed-&gt;setItem(row, 0, icon_item);
      ui-&gt;tableFeed-&gt;setItem(row, 1, item);
  }
  </code></pre>
  
  <p>And it just doesn't work. Nothing is displayed in that cell. Any ideas?</p>
  
  <p>EDIT: the setItem call where I set it to <code>icon</code> was a typo. The actual code sets it to the <code>QTabeWidgetItem icon_item</code>. I have corrected it in the code above.</p>