PDA

View Full Version : QWizard hides my QMainwindow instance upon showing and closes my app upon finishing o



nvdstruis
22nd November 2010, 20:52
I create a QWizard instance in a QMainwindow instance and show it with show(). When it is showed my mainwindow disappeares. When I finish or cancel the wizard, the application is closed. I have been searching and trying various things but still haven't got a clue. Can somebody help me out here, this makes no sense?

The code looks like this:
void MainWindow::startMyWizard()
{

pWizard_ = new CMyWizard( this );//CMyWizard directly derived from QWizard
pWizard_->show();

}

franz
22nd November 2010, 21:14
This code doesn't do anything odd. Got a more elaborate example? Preferably a working one that we can compile and see what goes wrong.

nvdstruis
22nd November 2010, 21:24
I seem to have found a working solution. I connected the accepted() and rejected() signals of the wizard to the show() slot of the main window. Now the only remaining issue is that upon showing the wizard, the main window disappeares, until the wizard is closed or finished. Don't know yet how to solve that.

The new code is:

void MainWindow::startMyWizard()
{
pMyWizard_ = new QWizard( this );
connect( pMyWizard_, SIGNAL( accepted() ), this, SLOT( show() ) );
connect( pMyWizard_, SIGNAL( rejected() ), this, SLOT( show() ) );
pMyWizard_->show();
}

Oh and b.t.w., I also had to call setQuitOnLastWindowClosed( false ) on the application(instance of QApplication in the main() function). If you want to have the whole code, let me know.