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 :
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:
tableWidget->setRowCount(4);
tableWidget->setColumnCount(1);
QTableWidget* tableWidget = new QTableWidget(0);
tableWidget->setRowCount(4);
tableWidget->setColumnCount(1);
tableWidget->setItem(0, 0, new QTableWidgetItem("x"));
tableWidget->setItem(1, 0, new QTableWidgetItem("x"));
tableWidget->setItem(2, 0, new QTableWidgetItem("x"));
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:
tableWidget->render(painter);
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???
Bookmarks