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
	
	MainWindow
::MainWindow(QWidget *parent
) :{
    setMinimumSize(800,600);
    QFormLayout *mainLayout=new QFormLayout();
    widget->setStyleSheet("height: 400px; width: 500px;");
    connect(onlineGameButton, SIGNAL(clicked()), this, SLOT(newOnlineGame()));
    connect(exitButton, SIGNAL(clicked()), this, SLOT(exitProgram()));
    btnsLayout->addWidget(onlineGameButton);
    btnsLayout->addWidget(offlineGameButton);
    btnsLayout->addWidget(simulateGameButton);
    btnsLayout->addWidget(optionsButton);
    btnsLayout->addWidget(exitButton);
    btnsLayout->addStretch();
    btns->setLayout(btnsLayout);
    mainLayout->addRow(btns, widget);
...
    tempWidget->setLayout(mainLayout);
    setCentralWidget(tempWidget);
}
        MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
{
    QWidget *tempWidget = new QWidget(this);
    setMinimumSize(800,600);
    QFormLayout *mainLayout=new QFormLayout();
    QVBoxLayout *btnsLayout=new QVBoxLayout;
    btns=new QGroupBox;
    widget=new QWidget;
    widget->setStyleSheet("height: 400px; width: 500px;");
    onlineGameButton=new QPushButton("ONLINE GAME");
    connect(onlineGameButton, SIGNAL(clicked()), this, SLOT(newOnlineGame()));
    offlineGameButton=new QPushButton("OFFLINE GAME");
    simulateGameButton=new QPushButton("SIMULATE GAME");
    optionsButton=new QPushButton("OPTIONS");
    exitButton=new QPushButton("EXIT");
    connect(exitButton, SIGNAL(clicked()), this, SLOT(exitProgram()));
    btnsLayout->addWidget(onlineGameButton);
    btnsLayout->addWidget(offlineGameButton);
    btnsLayout->addWidget(simulateGameButton);
    btnsLayout->addWidget(optionsButton);
    btnsLayout->addWidget(exitButton);
    btnsLayout->addStretch();
    btns->setLayout(btnsLayout);
    mainLayout->addRow(btns, widget);
...
    tempWidget->setLayout(mainLayout);
    setCentralWidget(tempWidget);
}
To copy to clipboard, switch view to plain text mode 
  
	
	void MainWindow::newOnlineGame()
{
    widget=new GameWidgetView;
}
        void MainWindow::newOnlineGame()
{
    widget=new GameWidgetView;
}
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
				
			
Bookmarks