Hi. I have same question with a little difference. I build a form with tab widget. After running, i make it unvisible, and call with another button click. On close the child form is deleting with own objects. My problem is, with tab widget. Because i call it with reference, so on child form close its deleting from heap. After that if i click the button second time, its crashing. I cant copy my existed tab widget, or cant create a copy. How can i do it ?

Here is my dirty code

Qt Code:
  1. void MainWindow::on_action_Config_triggered()
  2. {
  3. confw = new QDialog(this);
  4. confw->setModal(true);
  5. confw->setSizeGripEnabled(false);
  6.  
  7. confw->setObjectName("confwid");
  8. confw->setWindowTitle("Configuration");
  9.  
  10. QWidget *tab = new QWidget;
  11. tab = (QWidget *)ui->tab1; //existing tab widget object, which i created with qt creator for another mainwindow object
  12. tab->setParent(confw); // on confw delete, its deleting too. because i cant make it copy!!! :(
  13.  
  14. tab->show();
  15. confw->setMaximumSize((tab->width()+10),(tab->height()+10));
  16. confw->setMinimumSize((tab->width()+10),(tab->height()+10));
  17. ui->pushButton->setVisible(false);
  18. confw->resize(tab->size().width()+10,tab->size().height()+10);
  19. confw->setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter,confw->size(),
  20. qApp->desktop()->availableGeometry()));
  21.  
  22. QPushButton *pushbutton = new QPushButton(ui->groupBox_6);
  23. pushbutton->setText("Save");
  24. pushbutton->setGeometry(ui->pushButton->geometry());
  25. pushbutton->setIcon(ui->pushButton->icon());
  26. connect(pushbutton,SIGNAL(clicked()),this,SLOT(configcontrol()));
  27. connect(pushbutton,SIGNAL(clicked()),confw,SLOT(close()));
  28. ui->groupBox_6->setVisible(true);
  29. ui->groupBox_6->setEnabled(true);
  30. pushbutton->setVisible(true);
  31. pushbutton->setEnabled(true);
  32. pushbutton->show();
  33. confw->showNormal();
  34. }
To copy to clipboard, switch view to plain text mode 

Regards.