Hallo

I'm using 2 QTablewidgets which cells are filled with cellWidgets i.e QPushButton.
now I want to move those cellwidgets from one TableWidget to the other.

The cellWidgets I use look like this:

Qt Code:
  1. class Strip_t : public QPushButton
  2. {
  3. Q_OBJECT
  4. public:
  5. explicit Strip_t(QString, QWidget *parent = 0);
  6.  
  7. signals:
  8.  
  9. public slots:
  10.  
  11. };
  12.  
  13. #include "Strip.h"
  14.  
  15. Strip_t::Strip_t(QString _Txt, QWidget *parent) :
  16. QPushButton(parent)
  17. {
  18. QPalette Pal;
  19. QBrush Brush;
  20. setMinimumSize(500, 20);
  21. setMaximumSize(500, 20);
  22. setAutoFillBackground(true);
  23. Pal = palette();
  24. Brush = Pal.brush(QPalette::Button);
  25. Brush.setColor(Qt::blue);
  26. setPalette(Pal);
  27. setText(_Txt);
  28. }
To copy to clipboard, switch view to plain text mode 



The constructor of my Mainwindow looks like that.
Qt Code:
  1. class MainWindow : public QMainWindow
  2. {
  3. Q_OBJECT
  4.  
  5. public:
  6. explicit MainWindow(QWidget *parent = 0);
  7. ~MainWindow();
  8.  
  9. private:
  10. Ui::MainWindow *ui;
  11.  
  12. Strip_t* Strip;
  13. Strip_t* TStrip;
  14. };
  15.  
  16.  
  17. MainWindow::MainWindow(QWidget *parent) :
  18. QMainWindow(parent),
  19. ui(new Ui::MainWindow)
  20. {
  21. ui->setupUi(this);
  22.  
  23. Strip = new Strip_t("0", ui->tableWidget1);
  24. ui->tableWidget1->setCellWidget(0,0,Strip);
  25. Strip = new Strip_t("1", ui->tableWidget1);
  26. ui->tableWidget1->setCellWidget(1,0,Strip);
  27. Strip = new Strip_t("2", ui->tableWidget1);
  28. ui->tableWidget1->setCellWidget(2,0,Strip);
  29. Strip = new Strip_t("3", ui->tableWidget1);
  30. ui->tableWidget1->setCellWidget(3,0,Strip);
  31. Timer1Id = startTimer(1000);
  32. std::cout << "start Timer: " << Timer1Id << std::endl;
  33.  
  34. }
To copy to clipboard, switch view to plain text mode 

Now I want to move the a cellwidget to another cell:
Qt Code:
  1. Strip_t* Temp = ui->tableWidget1->cellWidget(3,0);
  2. ui->tableWidget2->setCellWidget(1,0,Temp);
To copy to clipboard, switch view to plain text mode 

that works

but if I try to restore it to it's former place

Qt Code:
  1. Strip_t* Temp = ui->tableWidget2->cellWidget(1,0);
  2. ui->tableWidget1->setCellWidget(3,0,Temp);
To copy to clipboard, switch view to plain text mode 


the cellwidget completely disappears ?(


Any ideas or tips what's going wrong?