PDA

View Full Version : QWizard



steg90
13th December 2007, 10:50
Hi,

I have some classes derived from QWidget. I want to display these one at a time, i.e.one screen, then the next screen, just like in a wizard.

This is the code I have :



QWizard wizard;
wizard.addPage( new QWizardPage( new CanView( this ) ) );
wizard.show();


The view gets displayed and then just exits? I normally show this view within a workspace as my app is mdi type.

Any reason for this?

Regards,
Steve

jpn
13th December 2007, 10:52
The wizard goes out of scope. Allocate it on the heap with 'new' or use blocking QDialog::exec() (QWizard is a QDialog).

steg90
13th December 2007, 11:00
Thanks

The wizard is now displayed, but the view isn't? Just a form with Finsish and Cancel button?

high_flyer
13th December 2007, 12:53
its because you are creating an empty wizard page with CanView object as its parent.
Make CanView a subclass of QWizardPage and ad *it* to the wizard.

P.S
I recommend you read some C++ basics

steg90
14th December 2007, 09:20
Thanks,

Although I don't need to go and read some C++ basics thank you very much, just wasn't so sure about using QWizardPage...

jpn
14th December 2007, 09:28
just wasn't so sure about using QWizardPage...
Neither was I since I never used it before. But the moment I opened QWizard docs and took a look at the detailed description, it was clear right away how to use it. You should do the same when using unfamiliar classes.

steg90
14th December 2007, 09:37
The views I was adding to the wizard I had already written a while back and they are all derived from QWidget which QWizardPage inherits so I just thought they would be ok without having to change their base class, ok, I should have thought more on this and obvioulsy the constructor for QWizardPage does more behind the scenes. Before the post back from High Flyer I had actually changed one of them to derive from QWizardPage, sorry to have not posted back to say I'd fixed it.:o