PDA

View Full Version : How to show a wizard before the main window?



dcopeto
27th March 2009, 01:29
Hi,

how can make the wizard show up alone, and then when it finishes, the main window comes up?

My main.cpp code is this:

int main(int argc, char ** argv)
{
QApplication app(argc, argv);

MainWindowImpl win;
win.show(); //shows the main window
win.data = new dataBase;
startWizard wizard(&win, &(win.data));
wizard.show(); //shows the wizard

app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}


thanks a bunch for the help,
david

ccp
27th March 2009, 05:09
Hi,

how can make the wizard show up alone, and then when it finishes, the main window comes up?

My main.cpp code is this:

int main(int argc, char ** argv)
{
QApplication app(argc, argv);

MainWindowImpl win;
win.show(); //shows the main window
win.data = new dataBase;
startWizard wizard(&win, &(win.data));
wizard.show(); //shows the wizard

app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}


thanks a bunch for the help,
david
Maybe this is what you need.

It wiil be simple if you use exec() for wizard. Mainwindow will show behind wizard, but not activated.

int main(int argc, char ** argv)
{
QApplication app( argc, argv );
MainWindowImpl win;
win.show();
app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );

startWizard wizard;
wizard.exec();
return app.exec();
}


Also maybe this might be what you want, but this will be a little bit complicated.
I haven't tested yet.
In startWizard class:
#include "mainwindowimpl.h"
#include <QtGui>

Class startWizard : public QWizard
{
public:
startWizard(MainWindowImpl *mainWindow);
~startWizard();
...
...
private:
MainWindowImpl *m_mainWindow;
};

In startwizard.cpp:
startWizard::~startWizard()
{
mainWindow->show();
}

startWizard::startWizard(MainWindowImpl *mainWindow)
{
m_mainWindow = mainWindow;
}

In main.cpp:
int main(int argc, char ** argv)
{
QApplication app( argc, argv );

MainWindowImpl win;

startWizard wizard(&win);
wizard.exec();
return app.exec();
}

I don't know if it helps.

aekilic
27th March 2009, 07:18
int main(int argc, char ** argv)
{
QApplication app(argc, argv);

MainWindowImpl win;
win.show(); //shows the main window
win.data = new dataBase;
startWizard wizard(&win, &(win.data));
wizard.show(); //shows the wizard

app.connect( &app, SIGNAL( lastWindowClosed() ), &app, SLOT( quit() ) );
return app.exec();
}
what you need to do is

include your startWizard .h to your main.cpp

after that you need to


startWizard sss;
sss.exec();


than continue to your main window

dcopeto
27th March 2009, 17:10
Hey thanks a lot ccp!! what you said worked! :D

I just had to put the m_mainWindow->show(); in my startWizard::accept() function instead of in the ~startWizard() like you suggested.


Thanks a lot!
Cheers,
david