Hi to all,
This is my first post, although I have followed this forum for some time and resolved many problems thanks to it.

I have a one column QTableWidget with each cell in a row containing a QwtPlot inside. I want to move up/down a plot in the table, so instead of using removeRow and insertRow, because the former deletes the plot inside the cell, I used in Qt 4.1.0 the following (simplified) code which works, given that setCellWidget just overrides the previous widget with the new one without deleting the previous one.


Qt Code:
  1. void SignalPlotFrame::moveUp(int row)
  2. {
  3. if (row > 0)
  4. {
  5. QwtPlot *plotOne = static_cast<QwtPlot*>(
  6. table->cellWidget (row - 1, 0));
  7. QwtPlot *plotTwo = static_cast<QwtPlot*>(
  8. table->cellWidget (row, 0));
  9. table->setCellWidget (row - 1, 0, plotTwo);
  10. table->setCellWidget (row, 0, plotOne);
  11. }
  12. }
To copy to clipboard, switch view to plain text mode 

Testing the same code with Qt 4.2.1, it does not work any more, and looking at the implementation of QTableWidget::setCellWidget and QAbstractItemView::setIndexWidget I saw that it changed from 4.1.0 and that now it first tests whether there was a widget in the cell before setting the new one, and if so it deletes it.

Is it possible with QTableWidget to remove/overright the old widget from a cell without deleting it? Or should I better invest some effort in implementing my own model/view/delegate classes for handling such situations?