Switch widgets in a QTableWidget
Hi everybody, I'm trying to use a QTableWidget who contains QWidget (not QItems).
I tried to switch two widgets using Drag&Drop but I found a problem:
-When I call the cellWidget(row,col) method I get the instance of QWidget, but the QTableWidget kept the reference to that QWidget, so when I use setCellWidget in the same (row,col) it remove the QWidget.
An example to clearify:
previousRow = rowAt(event->pos().y()); previousCol = columnAt(event->pos().x()); previousWidget = cellWidget(previousRow,previousCol);
QWidget *currentWidget = cellWidget(currentRow,currentCol); setCellWidget(currentRow,currentCol,previousWidget); setCellWidget(previousRow,previousCol,currentWidget);
When I do that, I remove both QWidget... I tried to set a null pointer to the cell (setCellWidget(row,col,0) after getting the cellWidget, but It didn't work...
Any idea? Thanks!