Hi, I'm making qt gui application, and in mainwindow I have QWidget, which should become one of my custom widgets..

here's a code

Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent)
  3. {
  4. QWidget *tempWidget = new QWidget(this);
  5. setMinimumSize(800,600);
  6. QFormLayout *mainLayout=new QFormLayout();
  7. QVBoxLayout *btnsLayout=new QVBoxLayout;
  8. btns=new QGroupBox;
  9. widget=new QWidget;
  10. widget->setStyleSheet("height: 400px; width: 500px;");
  11. onlineGameButton=new QPushButton("ONLINE GAME");
  12. connect(onlineGameButton, SIGNAL(clicked()), this, SLOT(newOnlineGame()));
  13. offlineGameButton=new QPushButton("OFFLINE GAME");
  14. simulateGameButton=new QPushButton("SIMULATE GAME");
  15. optionsButton=new QPushButton("OPTIONS");
  16. exitButton=new QPushButton("EXIT");
  17. connect(exitButton, SIGNAL(clicked()), this, SLOT(exitProgram()));
  18. btnsLayout->addWidget(onlineGameButton);
  19. btnsLayout->addWidget(offlineGameButton);
  20. btnsLayout->addWidget(simulateGameButton);
  21. btnsLayout->addWidget(optionsButton);
  22. btnsLayout->addWidget(exitButton);
  23. btnsLayout->addStretch();
  24. btns->setLayout(btnsLayout);
  25. mainLayout->addRow(btns, widget);
  26. ...
  27. tempWidget->setLayout(mainLayout);
  28. setCentralWidget(tempWidget);
  29. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void MainWindow::newOnlineGame()
  2. {
  3. widget=new GameWidgetView;
  4. }
To copy to clipboard, switch view to plain text mode 

i used debug to view if event is fired, and it is, but nothing happend, widget didn't become GameWidgetView...

widget is defined as private member of MainWindow, so when I add it to centralwidget, when i change widget, it should be changed and "that widget" in centralwidget, too, right(because of reference)?

sorry for my english