I have a table where I display mostly text, however in some cases some cells have a list of values.

I wanted to render those lists as a one column table within the cell. For that reason I made my own item delegate and overloaded the QitemDelegate : : paint() function.

Inside, if I do not detect a list I just pass the flow :

Qt Code:
  1. QItemDelegate::paint( painter, option, index );
To copy to clipboard, switch view to plain text mode 

However, if I have a list I want to build that table. For testing I have:
Qt Code:
  1. QTableWidget* tableWidget = new QTableWidget(0);
  2. tableWidget->setRowCount(4);
  3. tableWidget->setColumnCount(1);
  4.  
  5. tableWidget->setItem(0, 0, new QTableWidgetItem("x"));
  6. tableWidget->setItem(1, 0, new QTableWidgetItem("x"));
  7. tableWidget->setItem(2, 0, new QTableWidgetItem("x"));
  8. tableWidget->setItem(3, 0, new QTableWidgetItem("x"));
To copy to clipboard, switch view to plain text mode 

Now my idea was to use that QTableWidget to paint the table, an so far the only way I saw to pass a QPainter parameter was with the render function:

Qt Code:
  1. tableWidget->render(painter);
To copy to clipboard, switch view to plain text mode 

That does not work and the cell looks empty (with/within saving/restoring the state before using render() ). Any idea about how could I reuse the painter of QTableWidget to draw that table???