Hi,

I created 2 small examples with a QMainWindow that allows me to set the centralWidget using 4 widgets i created: graus000, graus090, graus180 and graus270.

I have 2 versions: v1 and v2.

v1 looks like this:
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent)
  5. : QMainWindow(parent), ui(new Ui::MainWindow)
  6. {
  7. ui->setupUi(this);
  8. }
  9.  
  10. MainWindow::~MainWindow()
  11. {
  12. delete ui;
  13. }
  14.  
  15. void MainWindow::on_actionVer_a_0_graus_triggered()
  16. {
  17. frm000 = new graus000Form;
  18. this->setCentralWidget(frm000);
  19. }
  20.  
  21. void MainWindow::on_actionVer_a_90_graus_triggered()
  22. {
  23. frm090 = new graus090Form;
  24. this->setCentralWidget(frm090);
  25. }
  26.  
  27. void MainWindow::on_actionVer_a_180_graus_triggered()
  28. {
  29. frm180 = new graus180Form;
  30. this->setCentralWidget(frm180);
  31. }
  32.  
  33. void MainWindow::on_actionVer_a_270_graus_triggered()
  34. {
  35. frm270 = new graus270Form;
  36. this->setCentralWidget(frm270);
  37. }
To copy to clipboard, switch view to plain text mode 
This works but it seems i'm wasting memory here!?

v2 looks like this:
Qt Code:
  1. #include "mainwindow.h"
  2. #include "ui_mainwindow.h"
  3.  
  4. MainWindow::MainWindow(QWidget *parent)
  5. : QMainWindow(parent), ui(new Ui::MainWindow)
  6. {
  7. ui->setupUi(this);
  8. frm000 = new graus000Form;
  9. frm090 = new graus090Form;
  10. frm180 = new graus180Form;
  11. frm270 = new graus270Form;
  12. }
  13.  
  14. MainWindow::~MainWindow()
  15. {
  16. delete ui;
  17. }
  18.  
  19. void MainWindow::on_actionVer_a_0_graus_triggered()
  20. {
  21. this->setCentralWidget(frm000);
  22. }
  23.  
  24. void MainWindow::on_actionVer_a_90_graus_triggered()
  25. {
  26. this->setCentralWidget(frm090);
  27. }
  28.  
  29. void MainWindow::on_actionVer_a_180_graus_triggered()
  30. {
  31. this->setCentralWidget(frm180);
  32. }
  33.  
  34. void MainWindow::on_actionVer_a_270_graus_triggered()
  35. {
  36. this->setCentralWidget(frm270);
  37. }
To copy to clipboard, switch view to plain text mode 
I set the centralWidget to graus000, then to othe value and then again to graus000 ... and it crashes.

Full examples here ( http://www.box.net/shared/ycvua1jarz ).

What's the best approach for doing what i'm trying to do here?

Thanks