PDA

View Full Version : Displaying 1 widget at time



afflictedd2
14th December 2008, 03:35
Hi everyone,

I'm building a gui that creates a mainwindow in which there are two toolbar icons, when you click on any of them a certain dialog should appear. I have done this but it is crashing because it's not closing one widget when the other one opens. I was wondering if there is a command that will clear the CentralWidget, so that the new dialog may open without crashing. Here's my code:


void MainWindow::dialog1()
{
if (!dialog) {
dialog = new Dialog1;
}
this->setCentralWidget( dialog );
dialog->show();
}


void MainWindow::dialog2()
{
if (!dialog2) {
dialog2 = new Dialog2;
}
this->setCentralWidget( dialog2 );
dialog2->show();
}

caduel
14th December 2008, 08:44
try using a QStackedWidget for that.

afflictedd2
14th December 2008, 16:23
I don't like the arrows in QStackedWidgets though, are these removable?

wysota
14th December 2008, 16:31
They are only visible in Designer so that you can switch pages easily when designing them. When you build your application, they will go away.