PDA

View Full Version : How to move back several pages in QWizard?



viet.nguyentien
5th November 2010, 01:41
Thank you for your times reading this question.

My wizard is a guidance for the end-users to setup a device. It has 8 steps.
Normally the wizard moves step-by-step from S1 to S8. But on the last page S8, the wizard opens a full-screen dialog and performs some tests on the device. If the test has passed, the wizard is ended. If the test has failed, the user need to go back to the S4 to check the device installation process again. It sounds simple, right?

On S8, when the user clicks on CustomButton1, I used this code to move back to S4:

restart();
while(wizard()->currentId() != 4) wizard()->button(QWizard::NextButton)->click();

It works! and the wizard moves to S4 flawlessly, but actually the user cannot see the CustomButton1 because the dialog is in full-screen mode. For that reason, I implemented another button on the dialog, and when the user clicks on that button, the following code will "click" the CustomButton1:

wizard()->button(QWizard::CustomButton1)->click();

It seems OK when the wizard moves back to S4 also, but the problem is: after going back to S4, if the user clicks on BACK button to move to S3, the first click doesn't make any change. The user always has to click twice to move back to S3.

Any suggestion will be appreciated.

ChrisW67
5th November 2010, 03:07
Creating non-linear wizards is described with examples (License Wizard Example) in the QWizard documentation. Essentially you give each page an ID, and then override QWizardPage::nextId() or QWizard::nextId() to drive where the next button takes you. In nextId() for S8 run the test and if it passes return -1 (i.e. end of wizard) otherwise return the id for S4.

viet.nguyentien
5th November 2010, 04:03
Thank ChrisW67 for your fast replying.
I tried as you suggested but the S8 can move forward (and skip some pages in the between), for example, to S11 not S4.

And the problem here is: there must be something difference between a real "hardware click" and the "software click" on the same button. If I use my mouse to hit the CustomButton1, it goes back to S4 flawlessly. If I click on other button, then that button fires a click to CustomButton1, the wizard still goes back to S4, but the BACK button on S4 must be clicked twice in case I want to move back to S3. Weird huh?